LeetCode Database Solution List


This is a list of LeetCode database problems and solutions. All problems and solutions are listed by difficulty levels.


Easy Problems

No.   Problem   Difficulty   Solution
175   Combine Two Tables   Easy   Link
176   Second Highest Salary   Easy   Link
181   Employees Earning More Than Their Managers   Easy   Link
182   Duplicate Emails   Easy   Link
183   Customers Who Never Order   Easy   Link
196   Delete Duplicate Emails   Easy   Link
197   Rising Temperature   Easy   Link
511   Game Play Analysis I   Easy   Link
512   Game Play Analysis II   Easy   Link
577   Employee Bonus   Easy   Link
584   Find Customer Referee   Easy   Link
586   Customer Placing The Largest Number Of Orders   Easy   Link
595   Big Countries   Easy   Link
596   Classes More Than 5 Students   Easy   Link
597   Friend Requests I: Overall Acceptance Rate   Easy   Link
603   Consecutive Available Seats   Easy   Link
607   Sales Person   Easy   Link
610   Triangle Judgement   Easy   Link
613   Shortest Distance In A Line   Easy   Link
619   Biggest Single Number   Easy   Link
620   Not Boring Movies   Easy   Link
627   Swap Salary   Easy   Link
1050   Actors And Directors Who Cooperated At Least Three Times   Easy   Link
1068   Product Sales Analysis I   Easy   Link
1069   Product Sales Analysis II   Easy   Link
1075   Project Employees I   Easy   Link
1076   Project Employees II   Easy   Link
1082   Sales Analysis I   Easy   Link
1083   Sales Analysis II   Easy   Link
1084   Sales Analysis III   Easy   Link
1113   Reported Posts   Easy   Link
1141   User Activity For The Past 30 Days I   Easy   Link
1142   User Activity For The Past 30 Days II   Easy   Link
1148   Article Views I   Easy   Link
1173   Immediate Food Delivery I   Easy   Link
1179   Reformat Department Table   Easy   Link
1211   Queries Quality And Percentage   Easy   Link
1241   Number Of Comments Per Post   Easy   Link
1251   Average Selling Price   Easy   Link
1280   Students And Examinations   Easy   Link
1294   Weather Type In Each Country   Easy   Link
1303   Find The Team Size   Easy   Link
1322   Ads Performance   Easy   Link
1327   List The Products Ordered In A Period   Easy   Link
1350   Students With Invalid Departments   Easy   Link
1378   Replace Employee ID With The Unique Identifier   Easy   Link
1407   Top Travellers   Easy   Link
1435   Create A Session Bar Chart   Easy   Link
1484   Group Sold Products By The Date   Easy   Link
1495   Friendly Movies Streamed Last Month   Easy   Link
1511   Customer Order Frequency   Easy   Link
1517   Find Users With Valid Emails   Easy   Link
1527   Patients With A Condition   Easy   Link
1543   Fix Product Name Format   Easy   Link
1565   Unique Orders And Customers Per Month   Easy   Link
1571   Warehouse Manager   Easy   Link
1581   Customer Who Visited But Did Not Make Any Transactions   Easy   Link
1587   Bank Account Summary II   Easy   Link
1607   Sellers With No Sales   Easy   Link
1623   All Valid Triplets That Can Represent A Country   Easy   Link
1633   Percentage Of Users Attended A Contest   Easy   Link
1661   Average Time Of Process Per Machine   Easy   Link
1667   Fix Names In A Table   Easy   Link
1677   Product’s Worth Over Invoices   Easy   Link
1683   Invalid Tweets   Easy   Link
1693   Daily Leads And Partners   Easy   Link
1729   Find Followers Count   Easy   Link
1731   The Number Of Employees Which Report To Each Employee   Easy   Link
1741   Find Total Time Spent By Each Employee   Easy   Link
1757   Recyclable And Low Fat Products   Easy   Link
1777   Product’s Price For Each Store   Easy   Link
1789   Primary Department For Each Employee   Easy   Link
1795   Rearrange Products Table   Easy   Link
1809   Ad-Free Sessions Table   Easy   Link
1821   Find Customers With Positive Revenue this Year   Easy   Link
1853   Convert Date Format   Easy   Link
1873   Calculate Special Bonus   Easy   Link
1890   The Latest Login in 2020   Easy   Link
1939   Users That Actively Request Confirmation Messages   Easy   Link
1965   Employees With Missing Information   Easy   Link
1978   Employees Whose Manager Left the Company   Easy   Link


Medium Problems

No.   Problem   Difficulty   Solution
177   Nth Highest Salary   Medium   Link
178   Rank Scores   Medium   Link
180   Consecutive Numbers   Medium   Link
184   Department Highest Salary   Medium   Link
534   Game Play Analysis III   Medium   Link
550   Game Play Analysis IV   Medium   Link
570   Managers With At Least 5 Direct Reports   Medium   Link
574   Winning Candidate   Medium   Link
578   Get Highest Answer Rate Question   Medium   Link
580   Count Student Number In Departments   Medium   Link
585   Investments In 2016   Medium   Link
602   Friend Requests II: Who Has The Most Friends   Medium   Link
608   Tree Node   Medium   Link
612   Shortest Distance In A Plane   Medium   Link
614   Second Degree Follower   Medium   Link
626   Exchange Seats   Medium   Link
1045   Customers Who Bought All Products   Medium   Link
1070   Product Sales Analysis III   Medium   Link
1077   Project Employees III   Medium   Link
1098   Unpopular Books   Medium   Link
1107   New Users Daily Count   Medium   Link
1112   Highest Grade For Each Student   Medium   Link
1126   Active Business   Medium   Link
1132   Reported Posts II   Medium   Link
1149   Article Views II   Medium   Link
1158   Market Analysis I   Medium   Link
1164   Product Price At A Given Date   Medium   Link
1174   Immediate Food Delivery II   Medium   Link
1193   Monthly Transactions I   Medium   Link
1204   Last Person To Fit In The Elevator   Medium   Link
1205   Monthly Transactions II   Medium   Link
1212   Team Scores In Football Tournament   Medium   Link
1264   Page Recommendations   Medium   Link
1270   All People Report To The Given Manager   Medium   Link
1285   Find The Start And End Number Of Continuous Ranges   Medium   Link
1308   Running Total For Different Genders   Medium   Link
1321   Restaurant Growth   Medium   Link
1341   Movie Rating   Medium   Link
1355   Activity Participants   Medium   Link
1364   Number Of Trusted Contacts Of A Customer   Medium   Link
1393   Capital Gain/Loss   Medium   Link
1398   Customers Who Bought Products A And B But Not C   Medium   Link
1421   NPV Queries   Medium   Link
1440   Evaluate Boolean Expression   Medium   Link
1445   Apples & Oranges   Medium   Link
1454   Active Users   Medium   Link
1459   Rectangles Area   Medium   Link
1468   Calculate Salaries   Medium   Link
1501   Countries You Can Safely Invest In   Medium   Link
1532   The Most Recent Three Orders   Medium   Link
1549   The Most Recent Orders For Each Product   Medium   Link
1555   Bank Account Summary   Medium   Link
1596   The Most Frequently Ordered Products For Each Customer   Medium   Link
1613   Find The Missing IDs   Medium   Link
1699   Number Of Calls Between Two Persons   Medium   Link
1709   Biggest Window Between Visits   Medium   Link
1715   Count Apples And Oranges   Medium   Link
1747   Leetflex Banned Accounts   Medium   Link
1783   Grand Slam Titles   Medium   Link
1811   Find Interview Candidates   Medium   Link
1831   Maximum Transaction Each Day   Medium   Link
1841   League Statistics   Medium   Link
1843   Suspicious Bank Accounts   Medium   Link
1867   Orders With Maximum Quantity Above Average   Medium   Link
1875   Group Employees of the Same Salary   Medium   Link
1907   Count Salary Categories   Medium   Link
1934   Confirmation Rate   Medium   Link
1949   Strong Friendship   Medium   Link
1951   All the Pairs With the Maximum Number of Common Followers   Medium   Link
1988   Find Cutoff Score for Each School   Medium   Link
1990   Count the Number of Experiments   Medium   Link


Hard Problems

No.   Problem   Difficulty   Solution
185   Department Top Three Salaries   Hard   Link
262   Trips And Users   Hard   Link
569   Median Employee Salary   Hard   Link
571   Find Median Given Frequency Of Numbers   Hard   Link
579   Find Cumulative Salary Of An Employee   Hard   Link
601   Human Traffic Of Stadium   Hard   Link
615   Average Salary: Departments VS Company   Hard   Link
618   Students Report By Geography   Hard   Link
1097   Game Play Analysis V   Hard   Link
1127   User Purchase Platform   Hard   Link
1159   Market Analysis II   Hard   Link
1194   Tournament Winners   Hard   Link
1225   Report Contiguous Dates   Hard   Link
1336   Number Of Transactions Per Visit   Hard   Link
1369   Get The Second Most Recent Activity   Hard   Link
1384   Total Sales Amount By Year   Hard   Link
1412   Find The Quiet Students In All Exams   Hard   Link
1479   Sales By Day Of The Week   Hard   Link
1635   Hopper Company Queries I   Hard   Link
1645   Hopper Company Queries II   Hard   Link
1651   Hopper Company Queries III   Hard   Link
1767   Find The Subtasks That Did Not Execute   Hard   Link
1892   Page Recommendations II   Hard   Link
1917   Leetcodify Friends Recommendations   Hard   Link
1919   Leetcodify Similar Friends   Hard   Link
1972   First and Last Call On the Same Day   Hard   Link





Related Posts

Git Short Answers List

A growing list of Git questions and short answers.

MySQL Tutorial List

A growing list of MySQL tutorials.

LeetCode Database Solution List

A list of LeetCode database problems and solutions.

LeetCode Solution List

A growing list of LeetCode problems and solutions.

Operating System Topic List

A growing list of posts under the topic of Operating...

Object Oriented Design Topic List

A growing list of posts under the topic of Object...