Skip to content

Commit a8883ba

Browse files
authored
Merge pull request codeharborhub#3128 from ananyag309/main
added leetcode soln of 2026
2 parents 0d04d6f + 3ca3590 commit a8883ba

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
id: low-quality-problems
3+
title: Low-Quality Problems
4+
sidebar_label: 2026 Low-Quality Problems
5+
tags:
6+
- SQL
7+
---
8+
9+
## Problem Description
10+
11+
You are given a table `Problems` with columns `problem_id`, `likes`, and `dislikes`. The `problem_id` is the primary key column representing the ID of each LeetCode problem, while `likes` and `dislikes` represent the number of likes and dislikes for each problem, respectively.
12+
13+
Write an SQL query to report the IDs of the low-quality problems. A LeetCode problem is considered low-quality if the like percentage (likes / (likes + dislikes)) is strictly less than 60%.
14+
15+
Return the result table ordered by `problem_id` in ascending order.
16+
17+
### Examples
18+
19+
**Example 1**
20+
21+
```
22+
Input
23+
24+
Problems table:
25+
+------------+-------+----------+
26+
| problem_id | likes | dislikes |
27+
+------------+-------+----------+
28+
| 6 | 1290 | 425 |
29+
| 11 | 2677 | 8659 |
30+
| 1 | 4446 | 2760 |
31+
| 7 | 8569 | 6086 |
32+
| 13 | 2050 | 4164 |
33+
| 10 | 9002 | 7446 |
34+
+------------+-------+----------+
35+
36+
Output:*
37+
38+
+------------+
39+
| problem_id |
40+
+------------+
41+
| 7 |
42+
| 10 |
43+
| 11 |
44+
| 13 |
45+
+------------+
46+
47+
Explanation:
48+
The like percentages are as follows:
49+
- Problem 1: (4446 / (4446 + 2760)) * 100 = 61.69858%
50+
- Problem 6: (1290 / (1290 + 425)) * 100 = 75.21866%
51+
- Problem 7: (8569 / (8569 + 6086)) * 100 = 58.47151%
52+
- Problem 10: (9002 / (9002 + 7446)) * 100 = 54.73006%
53+
- Problem 11: (2677 / (2677 + 8659)) * 100 = 23.61503%
54+
- Problem 13: (2050 / (2050 + 4164)) * 100 = 32.99002%
55+
56+
Problems 7, 10, 11, and 13 are low-quality problems because their like percentages are less than 60%.
57+
```
58+
59+
### Approach
60+
61+
To solve this problem, we need to:
62+
1. Calculate the like percentage for each problem using the formula `(likes / (likes + dislikes)) * 100`.
63+
2. Select the `problem_id` where the calculated like percentage is less than 60%.
64+
3. Order the results by `problem_id` in ascending order.
65+
66+
#### SQL Query
67+
68+
```sql
69+
SELECT problem_id
70+
FROM Problems
71+
WHERE likes * 100 / (likes + dislikes) < 60
72+
ORDER BY problem_id;
73+
```

0 commit comments

Comments
 (0)