Low-Quality Problems - Problem

You are given a table Problems that contains information about LeetCode problems, including the number of likes and dislikes for each problem.

Table: Problems

Column NameType
problem_idint
likesint
dislikesint

In SQL, problem_id is the primary key column for this table. Each row of this table indicates the number of likes and dislikes for a LeetCode problem.

Task: Find the IDs of the low-quality problems. A LeetCode problem is low-quality if the like percentage of the problem (number of likes divided by the total number of votes) is strictly less than 60%.

Return the result table ordered by problem_id in ascending order.

Table Schema

Problems
Column Name Type Description
problem_id PK int Unique identifier for each problem
likes int Number of likes for the problem
dislikes int Number of dislikes for the problem
Primary Key: problem_id
Note: Each row represents a LeetCode problem with its vote statistics

Input & Output

Example 1 — Mixed Quality Problems
Input Table:
problem_id likes dislikes
6 1290 425
11 2677 8659
7 24 40
Output:
problem_id
7
11
💡 Note:

Problem 6: Like percentage = 1290/(1290+425) = 1290/1715 ≈ 75.2% → Not low-quality (≥ 60%)

Problem 7: Like percentage = 24/(24+40) = 24/64 = 37.5% → Low-quality (< 60%)

Problem 11: Like percentage = 2677/(2677+8659) = 2677/11336 ≈ 23.6% → Low-quality (< 60%)

Results are ordered by problem_id: [7, 11]

Example 2 — All High Quality
Input Table:
problem_id likes dislikes
1 100 50
2 200 100
Output:
problem_id
💡 Note:

Problem 1: Like percentage = 100/(100+50) = 100/150 ≈ 66.7% → Not low-quality

Problem 2: Like percentage = 200/(200+100) = 200/300 ≈ 66.7% → Not low-quality

No problems have like percentage < 60%, so result is empty.

Example 3 — Boundary Case
Input Table:
problem_id likes dislikes
5 60 40
8 59 41
Output:
problem_id
8
💡 Note:

Problem 5: Like percentage = 60/(60+40) = 60/100 = 60.0% → Not low-quality (exactly 60%)

Problem 8: Like percentage = 59/(59+41) = 59/100 = 59.0% → Low-quality (< 60%)

Only problem 8 is strictly less than 60%.

Constraints

  • 1 ≤ problem_id ≤ 100
  • 0 ≤ likes ≤ 100
  • 0 ≤ dislikes ≤ 100
  • likes + dislikes > 0

Visualization

Tap to expand
SQL Overview: Finding Low-Quality ProblemsProblems Tableproblem_idlikesdislikes61290425112677865972440WHERE Clauselikes / (likes + dislikes) < 0.6Filters out problems with ≥ 60% likesResultproblem_id711Only problems with like percentage < 60% are returned
Understanding the Visualization
1
Input
Problems table with likes/dislikes
2
Calculate
Like percentage for each problem
3
Filter
Keep only problems < 60%
Key Takeaway
🎯 Key Insight: Use percentage calculations in WHERE clauses to filter data based on ratios
Asked in
Facebook 8 Amazon 5 Google 3
27.7K Views
Medium Frequency
~8 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen