{ "data": { "question": { "questionId": "1664", "questionFrontendId": "1517", "categoryTitle": "Database", "boundTopicId": 336736, "title": "Find Users With Valid E-Mails", "titleSlug": "find-users-with-valid-e-mails", "content": "
Table: Users
\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| user_id | int |\n| name | varchar |\n| mail | varchar |\n+---------------+---------+\nuser_id is the primary key (column with unique values) for this table.\nThis table contains information of the users signed up in a website. Some e-mails are invalid.\n\n\n
\n\n
Write a solution to find the users who have valid emails.
\n\nA valid e-mail has a prefix name and a domain where:
\n\n'_'
, period '.'
, and/or dash '-'
. The prefix name must start with a letter.'@leetcode.com'
.Return the result table in any order.
\n\nThe result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nUsers table:\n+---------+-----------+-------------------------+\n| user_id | name | mail |\n+---------+-----------+-------------------------+\n| 1 | Winston | winston@leetcode.com |\n| 2 | Jonathan | jonathanisgreat |\n| 3 | Annabelle | bella-@leetcode.com |\n| 4 | Sally | sally.come@leetcode.com |\n| 5 | Marwan | quarz#2020@leetcode.com |\n| 6 | David | david69@gmail.com |\n| 7 | Shapiro | .shapo@leetcode.com |\n+---------+-----------+-------------------------+\nOutput: \n+---------+-----------+-------------------------+\n| user_id | name | mail |\n+---------+-----------+-------------------------+\n| 1 | Winston | winston@leetcode.com |\n| 3 | Annabelle | bella-@leetcode.com |\n| 4 | Sally | sally.come@leetcode.com |\n+---------+-----------+-------------------------+\nExplanation: \nThe mail of user 2 does not have a domain.\nThe mail of user 5 has the # sign which is not allowed.\nThe mail of user 6 does not have the leetcode domain.\nThe mail of user 7 starts with a period.\n\n", "translatedTitle": "查找拥有有效邮箱的用户", "translatedContent": "
表: Users
\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| user_id | int |\n| name | varchar |\n| mail | varchar |\n+---------------+---------+\nuser_id 是该表的主键(具有唯一值的列)。\n该表包含了网站已注册用户的信息。有一些电子邮件是无效的。\n\n\n
\n\n
编写一个解决方案,以查找具有有效电子邮件的用户。
\n\n一个有效的电子邮件具有前缀名称和域,其中:
\n\n'_'
,点 '.'
和/或破折号 '-'
。前缀名称 必须 以字母开头。'@leetcode.com'
。以任何顺序返回结果表。
\n\n结果的格式如以下示例所示:
\n\n\n\n
示例 1:
\n\n\n输入:\nUsers 表:\n+---------+-----------+-------------------------+\n| user_id | name | mail |\n+---------+-----------+-------------------------+\n| 1 | Winston | winston@leetcode.com |\n| 2 | Jonathan | jonathanisgreat |\n| 3 | Annabelle | bella-@leetcode.com |\n| 4 | Sally | sally.come@leetcode.com |\n| 5 | Marwan | quarz#2020@leetcode.com |\n| 6 | David | david69@gmail.com |\n| 7 | Shapiro | .shapo@leetcode.com |\n+---------+-----------+-------------------------+\n输出:\n+---------+-----------+-------------------------+\n| user_id | name | mail |\n+---------+-----------+-------------------------+\n| 1 | Winston | winston@leetcode.com |\n| 3 | Annabelle | bella-@leetcode.com |\n| 4 | Sally | sally.come@leetcode.com |\n+---------+-----------+-------------------------+\n解释:\n用户 2 的电子邮件没有域。 \n用户 5 的电子邮件带有不允许的 '#' 符号。\n用户 6 的电子邮件没有 leetcode 域。 \n用户 7 的电子邮件以点开头。\n\n", "isPaidOnly": false, "difficulty": "Easy", "likes": 75, "dislikes": 0, "isLiked": null, "similarQuestions": "[]", "contributors": [], "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}", "topicTags": [ { "name": "Database", "slug": "database", "translatedName": "数据库", "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */", "__typename": "CodeSnippetNode" }, { "lang": "Pandas", "langSlug": "pythondata", "code": "import pandas as pd\n\ndef valid_emails(users: pd.DataFrame) -> pd.DataFrame:\n ", "__typename": "CodeSnippetNode" }, { "lang": "PostgreSQL", "langSlug": "postgresql", "code": "-- Write your PostgreSQL query statement below", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"18.2K\", \"totalSubmission\": \"34.3K\", \"totalAcceptedRaw\": 18212, \"totalSubmissionRaw\": 34327, \"acRate\": \"53.1%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "{\"headers\":{\"Users\":[\"user_id\",\"name\",\"mail\"]},\"rows\":{\"Users\":[[1,\"Winston\",\"winston@leetcode.com\"],[2,\"Jonathan\",\"jonathanisgreat\"],[3,\"Annabelle\",\"bella-@leetcode.com\"],[4,\"Sally\",\"sally.come@leetcode.com\"],[5,\"Marwan\",\"quarz#2020@leetcode.com\"],[6,\"David\",\"david69@gmail.com\"],[7,\"Shapiro\",\".shapo@leetcode.com\"]]}}", "metaData": "{\"mysql\":[\"Create table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))\"],\"mssql\":[\"Create table Users (user_id int, name varchar(30), mail varchar(50))\"],\"oraclesql\":[\"Create table Users (user_id int, name varchar(30), mail varchar(50))\"],\"database\":true,\"name\":\"valid_emails\",\"pythondata\":[\"Users = pd.DataFrame([], columns=['user_id', 'name', 'mail']).astype({'user_id':'int64', 'name':'object', 'mail':'object'})\"],\"postgresql\":[\"\\nCreate table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))\"],\"database_schema\":{\"Users\":{\"user_id\":\"INT\",\"name\":\"VARCHAR(30)\",\"mail\":\"VARCHAR(50)\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))", "Truncate table Users", "insert into Users (user_id, name, mail) values ('1', 'Winston', 'winston@leetcode.com')", "insert into Users (user_id, name, mail) values ('2', 'Jonathan', 'jonathanisgreat')", "insert into Users (user_id, name, mail) values ('3', 'Annabelle', 'bella-@leetcode.com')", "insert into Users (user_id, name, mail) values ('4', 'Sally', 'sally.come@leetcode.com')", "insert into Users (user_id, name, mail) values ('5', 'Marwan', 'quarz#2020@leetcode.com')", "insert into Users (user_id, name, mail) values ('6', 'David', 'david69@gmail.com')", "insert into Users (user_id, name, mail) values ('7', 'Shapiro', '.shapo@leetcode.com')" ], "enableRunCode": true, "envInfo": "{\"mysql\":[\"MySQL\",\"
\\u7248\\u672c\\uff1a mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\" Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\" Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\" PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Users\":[\"user_id\",\"name\",\"mail\"]},\"rows\":{\"Users\":[[1,\"Winston\",\"winston@leetcode.com\"],[2,\"Jonathan\",\"jonathanisgreat\"],[3,\"Annabelle\",\"bella-@leetcode.com\"],[4,\"Sally\",\"sally.come@leetcode.com\"],[5,\"Marwan\",\"quarz#2020@leetcode.com\"],[6,\"David\",\"david69@gmail.com\"],[7,\"Shapiro\",\".shapo@leetcode.com\"]]}}",
"__typename": "QuestionNode"
}
}
}MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"