Skip to content

Commit e6ffdd5

Browse files
committed
task: #3465
1 parent 8d60ed9 commit e6ffdd5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Useful for preparing for technical interviews and improving your SQL skills.
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)
155155
- [3436. Find Valid Emails](./leetcode/easy/3436.%20Find%20Valid%20Emails.sql)
156+
- [3465. Find Products with Valid Serial Numbers](./leetcode/easy/3465.%20Find%20Products%20with%20Valid%20Serial%20Numbers.sql)
156157
2. [Medium](./leetcode/medium/)
157158
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
158159
- [180. Consecutive Numbers](./leetcode/medium/180.%20Consecutive%20Numbers.sql)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Question 3465. Find Products with Valid Serial Numbers
3+
Link: https://leetcode.com/problems/find-products-with-valid-serial-numbers/description/?envType=problem-list-v2&envId=database
4+
5+
Table: products
6+
7+
+--------------+------------+
8+
| Column Name | Type |
9+
+--------------+------------+
10+
| product_id | int |
11+
| product_name | varchar |
12+
| description | varchar |
13+
+--------------+------------+
14+
(product_id) is the unique key for this table.
15+
Each row in the table represents a product with its unique ID, name, and description.
16+
Write a solution to find all products whose description contains a valid serial number pattern. A valid serial number follows these rules:
17+
18+
It starts with the letters SN (case-sensitive).
19+
Followed by exactly 4 digits.
20+
It must have a hyphen (-) followed by exactly 4 digits.
21+
The serial number must be within the description (it may not necessarily start at the beginning).
22+
Return the result table ordered by product_id in ascending order.
23+
*/
24+
25+
SELECT
26+
product_id,
27+
product_name,
28+
description --noqa
29+
FROM products
30+
WHERE description ~ '\ySN[0-9]{4}\-[0-9]{4}\y'
31+
ORDER BY product_id ASC

0 commit comments

Comments
 (0)