Skip to content

Latest commit

 

History

History
109 lines (100 loc) · 17.9 KB

sql-database.md

File metadata and controls

109 lines (100 loc) · 17.9 KB

Database / SQL LeetCode Problems

A collection of LeetCode problems solved using Database / SQL pattern techniques, explanations, and complexity analysis.

Problems

Easy

# Problem Language Time Space Explanation
175 Combine Two Tables SQL O(n) O(n) Explanation
181 Employees Earning More Than Their Managers SQL O(n) O(n) Explanation
182 Duplicate Emails SQL O(n) O(n) Explanation
183 Customers Who Never Order SQL O(n) O(n) Explanation
196 Delete Duplicate Emails SQL O(n) O(n) Explanation
197 Rising Temperature SQL O(n) O(n) Explanation
577 Employee Bonus SQL O(n) O(n) Explanation
584 Find Customer Referee SQL O(n) O(n) Explanation
586 Customer Placing the Largest Number of Orders SQL O(n) O(n) Explanation
595 Big Countries SQL O(n) O(n) Explanation
596 Classes With at Least 5 Students SQL O(n) O(n) Explanation
607 Sales Person SQL O(n) O(n) Explanation
610 Triangle Judgement SQL O(n) O(n) Explanation
619 Biggest Single Number SQL O(n) O(n) Explanation
620 Not Boring Movies SQL O(n) O(n) Explanation
627 Swap Sex of Employees SQL O(n) O(n) Explanation
1050 Actors and Directors Who Cooperated At Least Three Times SQL O(n) O(n) Explanation
1068 Product Sales Analysis I SQL O(n) O(n) Explanation
1075 Project Employees I SQL O(n) O(n) Explanation
1084 Sales Analysis III SQL O(n) O(n) Explanation
1141 User Activity for the Past 30 Days I SQL O(n) O(n) Explanation
1148 Article Views I SQL O(n) O(n) Explanation
1179 Reformat Department Table SQL O(n) O(n) Explanation
1211 Queries Quality and Percentage SQL O(n) O(n) Explanation
1251 Average Selling Price SQL O(n) O(n) Explanation
1280 Students and Examinations SQL O(n) O(n) Explanation
1327 List the Products Ordered in a Period SQL O(n) O(n) Explanation
1378 Replace Employee ID With The Unique Identifier SQL O(n) O(n) Explanation
1407 Top Travellers SQL O(n) O(n) Explanation
1484 Group Sold Products By The Date SQL O(n) O(n) Explanation
1517 Find Users With Valid E-Mails SQL O(n) O(n) Explanation
1527 Patients With a Condition SQL O(n) O(n) Explanation
1581 Customer Who Visited but Did Not Make Any Transactions SQL O(n) O(n) Explanation
1587 Bank Account Summary II SQL O(n) O(n) Explanation
1633 Percentage of Users Attended a Contest SQL O(n) O(n) Explanation
1661 Average Time of Process per Machine SQL O(n) O(n) Explanation
1667 Fix Names in a Table SQL O(n) O(n) Explanation
1683 Invalid Tweets SQL O(n) O(n) Explanation
1693 Daily Leads and Partners SQL O(n) O(n) Explanation
1729 Find Followers Count SQL O(n) O(n) Explanation
1731 The Number of Employees Which Report to Each Employee SQL O(n) O(n) Explanation
1741 Find Total Time Spent by Each Employee SQL O(n) O(n) Explanation
1757 Recyclable and Low Fat Products SQL O(n) O(n) Explanation
1789 Primary Department for Each Employee SQL O(n) O(n) Explanation
1795 Rearrange Products Table SQL O(n) O(n) Explanation
1873 Calculate Special Bonus SQL O(n) O(n) Explanation
1890 The Latest Login in 2020 SQL O(n) O(n) Explanation
1965 Employees With Missing Information SQL O(n) O(n) Explanation
1978 Employees Whose Manager Left the Company SQL O(n) O(n) Explanation
2356 Number of Unique Subjects Taught by Each Teacher SQL O(n) O(n) Explanation
3436 Find Valid Emails SQL O(n) O(n) Explanation
3465 Find Products with Valid Serial Numbers SQL O(n) O(n) Explanation
3793 Find Users with High Token Usage SQL O(n) O(n) Explanation

Medium

# Problem Language Time Space Explanation
176 Second Highest Salary SQL O(n) O(n) Explanation
177 Nth Highest Salary SQL O(n) O(n) Explanation
178 Rank Scores SQL O(n) O(n) Explanation
180 Consecutive Numbers SQL O(n) O(n) Explanation
184 Department Highest Salary SQL O(n) O(n) Explanation
585 Investments in 2016 SQL O(n) O(n) Explanation
602 Friend Requests II: Who Has the Most Friends SQL O(n) O(n) Explanation
608 Tree Node SQL O(n) O(n) Explanation
626 Exchange Seats SQL O(n) O(n) Explanation
1045 Customers Who Bought All Products SQL O(n) O(n) Explanation
1070 Product Sales Analysis III SQL O(n) O(n) Explanation
1158 Market Analysis I SQL O(n) O(n) Explanation
1164 Product Price at a Given Date SQL O(n) O(n) Explanation
1174 Immediate Food Delivery II SQL O(n) O(n) Explanation
1193 Monthly Transactions I SQL O(n) O(n) Explanation
1204 Last Person to Fit in the Bus SQL O(n) O(n) Explanation
1321 Restaurant Growth SQL O(n) O(n) Explanation
1341 Movie Rating SQL O(n) O(n) Explanation
1393 Capital Gain/Loss SQL O(n) O(n) Explanation
1907 Count Salary Categories SQL O(n) O(n) Explanation
1934 Confirmation Rate SQL O(n) O(n) Explanation
3220 Odd and Even Transactions SQL O(n) O(n) Explanation
3421 Find Students Who Improved SQL O(n) O(n) Explanation
3626 Find Stores with Inventory Imbalance SQL O(n) O(n) Explanation
3642 Find Books with Polarized Opinions SQL O(n) O(n) Explanation
3657 Find Loyal Customers SQL O(n) O(n) Explanation
3808 Find Emotionally Consistent Users SQL O(n) O(n) Explanation

Hard

# Problem Language Time Space Explanation
185 Department Top Three Salaries SQL O(n) O(n) Explanation
262 Trips and Users SQL O(n) O(n) Explanation
601 Human Traffic of Stadium SQL O(n) O(n) Explanation
3451 Find Invalid IP Addresses SQL O(n) O(n) Explanation
3617 Find Students with Study Spiral Pattern SQL O(n) O(n) Explanation
3673 Find Zombie Sessions SQL O(n) O(n) Explanation
3764 Most Common Course Pairs SQL O(n) O(n) Explanation
3832 Find Users with Persistent Behavior Patterns SQL O(n) O(n) Explanation