Skip to content

Commit 7aaed02

Browse files
committed
task: #3436
1 parent 0b0539d commit 7aaed02

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Useful for preparing for technical interviews and improving your SQL skills.
152152
- [1965. Employees With Missing Information](./leetcode/easy/1965.%20Employees%20With%20Missing%20Information.sql)
153153
- [1978. Employees Whose Manager Left the Company](./leetcode/easy/1978.%20Employees%20Whose%20Manager%20Left%20the%20Company.sql)
154154
- [2356. Number of Unique Subjects Taught by Each Teacher](./leetcode/easy/2356.%20Number%20of%20Unique%20Subjects%20Taught%20by%20Each%20Teacher.sql)
155+
- [3436. Find Valid Emails](./leetcode/easy/3436.%20Find%20Valid%20Emails.sql)
155156
2. [Medium](./leetcode/medium/)
156157
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
157158
- [180. Consecutive Numbers](./leetcode/medium/180.%20Consecutive%20Numbers.sql)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Question 3436. Find Valid Emails
3+
Link: https://leetcode.com/problems/find-valid-emails/description/?envType=problem-list-v2&envId=database
4+
5+
Table: Users
6+
7+
+-----------------+---------+
8+
| Column Name | Type |
9+
+-----------------+---------+
10+
| user_id | int |
11+
| email | varchar |
12+
+-----------------+---------+
13+
(user_id) is the unique key for this table.
14+
Each row contains a user's unique ID and email address.
15+
Write a solution to find all the valid email addresses. A valid email address meets the following criteria:
16+
17+
It contains exactly one @ symbol.
18+
It ends with .com.
19+
The part before the @ symbol contains only alphanumeric characters and underscores.
20+
The part after the @ symbol and before .com contains a domain name that contains only letters.
21+
Return the result table ordered by user_id in ascending order.
22+
*/
23+
24+
SELECT
25+
user_id,
26+
email
27+
FROM Users
28+
WHERE email ~ '^([a-zA-Z0-9]?[_]?[a-zA-Z0-9]?)*@[a-zA-Z]+\.com$'
29+
ORDER BY user_id ASC

0 commit comments

Comments
 (0)