Practice Find Valid Emails
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Table Users has user_id INT and email VARCHAR. Keep addresses with one @, a nonempty local part containing only English letters, digits, or underscores, and a nonempty letter-only domain followed by the literal suffix .com. Return user_id and email ordered by user_id ascending. These are this exercise's rules, not a general-purpose email standard. Practice approach: Use a whole-string match for the local part, @, domain, and escaped dot before com. Do not allow punctuation in the local part, digits in the domain, extra @ characters, or trailing text. Test the actual case behavior of the database regex operator.
Source: Find Valid Emails on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
{
"Users": [
{
"user_id": 1,
"email": "a_2@Mail.com"
},
{
"user_id": 2,
"email": "a.b@mail.com"
},
{
"user_id": 3,
"email": "a@ma1l.com"
},
{
"user_id": 4,
"email": "a@@mail.com"
},
{
"user_id": 5,
"email": "b@mail.comx"
},
{
"user_id": 6,
"email": "b@mail.com"
}
]
}[
{
"user_id": 1,
"email": "a_2@Mail.com"
},
{
"user_id": 6,
"email": "b@mail.com"
}
]An underscore and digit are allowed before @, but a dot there or a digit in the domain is not.
Constraints
Related LeetCode Problems
Practice more problems similar to Find Valid Emails.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.