|
| 1 | +<h2><a href="https://leetcode.com/problems/find-users-with-valid-e-mails/?envType=study-plan-v2&envId=top-sql-50">1664. Find Users With Valid E-Mails</a></h2><h3>Easy</h3><hr><p>Table: <code>Users</code></p> |
| 2 | + |
| 3 | +<pre> |
| 4 | ++---------------+---------+ |
| 5 | +| Column Name | Type | |
| 6 | ++---------------+---------+ |
| 7 | +| user_id | int | |
| 8 | +| name | varchar | |
| 9 | +| mail | varchar | |
| 10 | ++---------------+---------+ |
| 11 | +user_id is the primary key (column with unique values) for this table. |
| 12 | +This table contains information of the users signed up in a website. Some e-mails are invalid. |
| 13 | +</pre> |
| 14 | + |
| 15 | +<p> </p> |
| 16 | + |
| 17 | +<p>Write a solution to find the users who have <strong>valid emails</strong>.</p> |
| 18 | + |
| 19 | +<p>A valid e-mail has a prefix name and a domain where:</p> |
| 20 | + |
| 21 | +<ul> |
| 22 | + <li><strong>The prefix name</strong> is a string that may contain letters (upper or lower case), digits, underscore <code>'_'</code>, period <code>'.'</code>, and/or dash <code>'-'</code>. The prefix name <strong>must</strong> start with a letter.</li> |
| 23 | + <li><strong>The domain</strong> is <code>'@leetcode.com'</code>.</li> |
| 24 | +</ul> |
| 25 | + |
| 26 | +<p>Return the result table in <strong>any order</strong>.</p> |
| 27 | + |
| 28 | +<p>The result format is in the following example.</p> |
| 29 | + |
| 30 | +<p> </p> |
| 31 | +<p><strong class="example">Example 1:</strong></p> |
| 32 | + |
| 33 | +<pre> |
| 34 | +<strong>Input:</strong> |
| 35 | +Users table: |
| 36 | ++---------+-----------+-------------------------+ |
| 37 | +| user_id | name | mail | |
| 38 | ++---------+-----------+-------------------------+ |
| 39 | +| 1 | Winston | [email protected] | |
| 40 | +| 2 | Jonathan | jonathanisgreat | |
| 41 | +| 3 | Annabelle | [email protected] | |
| 42 | + |
| 43 | +| 5 | Marwan | quarz# [email protected] | |
| 44 | + |
| 45 | +| 7 | Shapiro | [email protected] | |
| 46 | ++---------+-----------+-------------------------+ |
| 47 | +<strong>Output:</strong> |
| 48 | ++---------+-----------+-------------------------+ |
| 49 | +| user_id | name | mail | |
| 50 | ++---------+-----------+-------------------------+ |
| 51 | +| 1 | Winston | [email protected] | |
| 52 | +| 3 | Annabelle | [email protected] | |
| 53 | + |
| 54 | ++---------+-----------+-------------------------+ |
| 55 | +<strong>Explanation:</strong> |
| 56 | +The mail of user 2 does not have a domain. |
| 57 | +The mail of user 5 has the # sign which is not allowed. |
| 58 | +The mail of user 6 does not have the leetcode domain. |
| 59 | +The mail of user 7 starts with a period. |
| 60 | +</pre> |
0 commit comments