LeetCode Solution List


This is a growing list of LeetCode problems and solutions. All problems and solutions are listed under different categories.


Algorithm And Data Structure

No.   Problem   Difficulty   Solution
1   Two Sum   Easy   Link
2   Add Two Numbers   Medium   Link
3   Longest Substring Without Repeating Characters   Medium   Link
4   Median Of Two Sorted Arrays   Hard   Link
5   Longest Palindromic Substring   Medium   Link
6   Zigzag Conversion   Medium   Link
7   Reverse Integer   Medium   Link
8   String To Integer (atoi)   Medium   Link
9   Palindrome Number   Easy   Link
10   Regular Expression Matching   Hard   Link
11   Container With Most Water   Medium   Link
12   Integer To Roman   Medium   Link
13   Roman To Integer   Easy   Link
14   Longest Common Prefix   Easy   Link
15   Three Sum   Medium   Link
16   3Sum Closest   Medium   Link
17   Letter Combinations Of A Phone Number   Medium   Link
18   Four Sum   Medium   Link
19   Remove Nth Node From End Of List   Medium   Link
20   Valid Parentheses   Easy   Link
21   Merge Two Sorted Lists   Easy   Link
22   Generate Parentheses   Medium   Link
23   Merge K Sorted Lists   Hard   Link
24   Swap Nodes In Pairs   Medium   Link
25   Reverse Nodes In K-Group   Hard   Link
26   Remove Duplicates From Sorted Array   Easy   Link
27   Remove Element   Easy   Link
28   Implement strStr()   Easy   Link
29   Divide Two Integers   Medium   Link
30   Substring with Concatenation of All Words   Hard   Link
31   Next Permutation   Medium   Link
32   Longest Valid Parentheses   Hard   Link
33   Search in Rotated Sorted Array   Medium   Link
34   Find First and Last Position of Element in Sorted Array   Medium   Link
35   Search Insert Position   Easy   Link
36   Valid Sudoku   Medium   Link
37   Sudoku Solver   Hard   Link
38   Count And Say   Medium   Link
39   Combination Sum   Medium   Link
40   Combination Sum II   Medium   Link
41   First Missing Positive   Hard   Link
42   Trapping Rain Water   Hard   Link
43   Multiply Strings   Medium   Link
44   Wildcard Matching   Hard   Link
45   Jump Game II   Medium   Link
46   Permutations   Medium   Link
47   Permutations II   Medium   Link
48   Rotate Image   Medium   Link
49   Group Anagrams   Medium   Link
50   Pow(x,n)   Medium   Link
51   N-Queens   Hard   Link
52   N-Queens II   Hard   Link
53   Maximum Subarray   Easy   Link
54   Spiral Matrix   Medium   Link
55   Jump Game   Medium   Link
56   Merge Intervals   Medium   Link
57   Insert Interval   Medium   Link
58   Length Of Last Word   Easy   Link
59   Spiral Matrix II   Medium   Link
60   Permutation Sequence   Hard   Link
61   Rotate List   Medium   Link
62   Unique Paths   Medium   Link
63   Unique Paths II   Medium   Link
64   Minimum Path Sum   Medium   Link
65   Valid Number   Hard   Link
66   Plus One   Easy   Link
67   Add Binary   Easy   Link
68   Text Justification   Hard   Link
69   Sqrt(x)   Easy   Link
70   Climbing Stairs   Easy   Link
71   Simplify Path   Medium   Link
72   Edit Distance   Hard   Link
73   Set Matrix Zeroes   Medium   Link
74   Search A 2D Matrix   Medium   Link
75   Sort Colors   Medium   Link
76   Minimum Window Substring   Hard   Link
77   Combinations   Medium   Link
78   Subsets   Medium   Link
79   Word Search   Medium   Link
80   Remove Duplicates From Sorted Array II   Medium   Link
81   Search In Rotated Sorted Array II   Medium   Link
82   Remove Duplicates From Sorted List II   Medium   Link
83   Remove Duplicates From Sorted List   Easy   Link
84   Largest Rectangle In Histogram   Hard   Link
85   Maximal Rectangle   Hard   Link
86   Partition List   Medium   Link
87   Scramble String   Hard   Link
88   Merge Sorted Array   Easy   Link
89   Gray Code   Medium   Link
90   Subsets II   Medium   Link
91   Decode Ways   Medium   Link
92   Reverse Linked List II   Medium   Link
93   Restore IP Addresses   Medium   Link
94   Binary Tree Inorder Traversal   Easy   Link
95   Unique Binary Search Trees II   Medium   Link
96   Unique Binary Search Trees   Medium   Link
97   Interleaving String   Medium   Link
98   Validate Binary Search Tree   Medium   Link
99   Recover Binary Search Tree   Medium   Link
100   Same Tree   Easy   Link
101   Symmetric Tree   Easy   Link
102   Binary Tree Level Order Traversal   Medium   Link
103   Binary Tree Zigzag Level Order Traversal   Medium   Link
104   Maximum Depth Of Binary Tree   Easy   Link
105   Construct Binary Tree From Preorder And Inorder Traversal   Medium   Link
106   Construct Binary Tree From Inorder And Postorder Traversal   Medium   Link
107   Binary Tree Level Order Traversal II   Medium   Link
108   Convert Sorted Array To Binary Search Tree   Easy   Link
109   Convert Sorted List To Binary Search Tree   Medium   Link
110   Balanced Binary Tree   Easy   Link
111   Minimum Depth Of Binary Tree   Easy   Link
112   Path Sum   Easy   Link
113   Path Sum II   Medium   Link
114   Flatten Binary Tree To Linked List   Medium   Link
115   Distinct Subsequences   Hard   Link
116   Populating Next Right Pointers In Each Node   Medium   Link
117   Populating Next Right Pointers In Each Node II   Medium   Link
118   Pascal’s Triangle   Easy   Link
119   Pascal’s Triangle II   Easy   Link
120   Triangle   Medium   Link
121   Best Time To Buy And Sell Stock   Easy   Link
122   Best Time To Buy And Sell Stock II   Medium   Link
123   Best Time To Buy And Sell Stock III   Hard   Link
124   Binary Tree Maximum Path Sum   Hard   Link
125   Valid Palindrome   Easy   Link
126   Word Ladder II   Hard   Link
127   Word Ladder   Hard   Link
128   Longest Consecutive Sequence   Medium   Link
129   Sum Root To Leaf Numbers   Medium   Link
130   Surrounded Regions   Medium   Link
167   Two Sum Input Array Is Sorted   Easy   Link
200   Number of Islands   Medium   Link
206   Reverse Linked List   Easy   Link
208   Implement Trie (Prefix Tree)   Medium   Link
212   Word Search II   Hard   Link
234   Palindrome Linked List   Easy   Link
349   Intersection Of Two Arrays   Easy   Link
367   Valid Perfect Square   Easy   Link
380   Insert Delete GetRandom O(1)   Easy   Link
421   Maximum XOR of Two Numbers In An Array   Medium   Link
454   Four Sum II   Medium   Link
472   Concatenate Words   Hard   Link
523   Continuous Subarray Sum   Medium   Link
543   Diameter Of Binary Tree   Easy   Link
560   Subarray Sum Equals K   Medium   Link
648   Replace Words   Medium   Link
713   Subarray Product Less Than K   Medium   Link
720   Longest Word In Dictionary   Easy   Link
771   Jewels And Stones   Easy   Link
961   N-Repeated Element In Size 2N Array   Easy   Link
974   Subarray Sum Divisible By K   Medium   Link
1023   Camelcase Matching   Medium   Link
1032   Stream Of Characters   Hard   Link
1099   Two Sum Less Than K   Easy   Link
1213   Intersection Of Three Sorted Arrays   Easy   Link
1224   Maximum Equal Frequency   Hard   Link
1438   Longest Continuous Subarray With Absolute Diff Less Than Or Equal To Limit   Medium   Link
1521   Number Of Good Pairs   Easy   Link
1539   Kth Missing Positive Number   Easy   Link
1539   Kth Missing Positive Number   Easy   Link
1748   Sum Of Unique Elements   Easy   Link
1812   Determine Color Of A Chessboard Square   Easy   Link
1902   Depth of BST Given Insertion Order   Medium   Link
1999   Smallest Greater Multiple Made of Two Digits   Medium   Link
2000   Reverse Prefix of Word   Easy   Link


Database

No.   Problem   Difficulty   Solution
175   Combine Two Tables   Easy   Link
176   Second Highest Salary   Easy   Link
177   Nth Highest Salary   Medium   Link
178   Rank Scores   Medium   Link
180   Consecutive Numbers   Medium   Link
181   Employees Earning More Than Their Managers   Easy   Link
182   Duplicate Emails   Easy   Link
183   Customers Who Never Order   Easy   Link
184   Department Highest Salary   Medium   Link
185   Department Top Three Salaries   Hard   Link
196   Delete Duplicate Emails   Easy   Link
197   Rising Temperature   Easy   Link
262   Trips And Users   Hard   Link
511   Game Play Analysis I   Easy   Link
512   Game Play Analysis II   Easy   Link
534   Game Play Analysis III   Medium   Link
550   Game Play Analysis IV   Medium   Link
569   Median Employee Salary   Hard   Link
570   Managers With At Least 5 Direct Reports   Medium   Link
571   Find Median Given Frequency Of Numbers   Hard   Link
574   Winning Candidate   Medium   Link
577   Employee Bonus   Easy   Link
578   Get Highest Answer Rate Question   Medium   Link
579   Find Cumulative Salary Of An Employee   Hard   Link
580   Count Student Number In Departments   Medium   Link
584   Find Customer Referee   Easy   Link
585   Investments In 2016   Medium   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
601   Human Traffic Of Stadium   Hard   Link
602   Friend Requests II: Who Has The Most Friends   Medium   Link
603   Consecutive Available Seats   Easy   Link
607   Sales Person   Easy   Link
608   Tree Node   Medium   Link
610   Triangle Judgement   Easy   Link
612   Shortest Distance In A Plane   Medium   Link
613   Shortest Distance In A Line   Easy   Link
614   Second Degree Follower   Medium   Link
615   Average Salary: Departments VS Company   Hard   Link
618   Students Report By Geography   Hard   Link
619   Biggest Single Number   Easy   Link
620   Not Boring Movies   Easy   Link
626   Exchange Seats   Medium   Link
627   Swap Salary   Easy   Link
1045   Customers Who Bought All Products   Medium   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
1070   Product Sales Analysis III   Medium   Link
1075   Project Employees I   Easy   Link
1076   Project Employees II   Easy   Link
1077   Project Employees III   Medium   Link
1082   Sales Analysis I   Easy   Link
1083   Sales Analysis II   Easy   Link
1084   Sales Analysis III   Easy   Link
1097   Game Play Analysis V   Hard   Link
1098   Unpopular Books   Medium   Link
1107   New Users Daily Count   Medium   Link
1112   Highest Grade For Each Student   Medium   Link
1113   Reported Posts   Easy   Link
1126   Active Business   Medium   Link
1127   User Purchase Platform   Hard   Link
1132   Reported Posts II   Medium   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
1149   Article Views II   Medium   Link
1158   Market Analysis I   Medium   Link
1159   Market Analysis II   Hard   Link
1164   Product Price At A Given Date   Medium   Link
1173   Immediate Food Delivery I   Easy   Link
1174   Immediate Food Delivery II   Medium   Link
1179   Reformat Department Table   Easy   Link
1193   Monthly Transactions I   Medium   Link
1194   Tournament Winners   Hard   Link
1204   Last Person To Fit In The Elevator   Medium   Link
1205   Monthly Transactions II   Medium   Link
1211   Queries Quality And Percentage   Easy   Link
1212   Team Scores In Football Tournament   Medium   Link
1225   Report Contiguous Dates   Hard   Link
1241   Number Of Comments Per Post   Easy   Link
1251   Average Selling Price   Easy   Link
1264   Page Recommendations   Medium   Link
1270   All People Report To The Given Manager   Medium   Link
1280   Students And Examinations   Easy   Link
1285   Find The Start And End Number Of Continuous Ranges   Medium   Link
1294   Weather Type In Each Country   Easy   Link
1303   Find The Team Size   Easy   Link
1308   Running Total For Different Genders   Medium   Link
1321   Restaurant Growth   Medium   Link
1322   Ads Performance   Easy   Link
1327   List The Products Ordered In A Period   Easy   Link
1336   Number Of Transactions Per Visit   Hard   Link
1341   Movie Rating   Medium   Link
1350   Students With Invalid Departments   Easy   Link
1355   Activity Participants   Medium   Link
1364   Number Of Trusted Contacts Of A Customer   Medium   Link
1369   Get The Second Most Recent Activity   Hard   Link
1378   Replace Employee ID With The Unique Identifier   Easy   Link
1384   Total Sales Amount By Year   Hard   Link
1393   Capital Gain/Loss   Medium   Link
1398   Customers Who Bought Products A And B But Not C   Medium   Link
1407   Top Travellers   Easy   Link
1412   Find The Quiet Students In All Exams   Hard   Link
1421   NPV Queries   Medium   Link
1435   Create A Session Bar Chart   Easy   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
1479   Sales By Day Of The Week   Hard   Link
1484   Group Sold Products By The Date   Easy   Link
1495   Friendly Movies Streamed Last Month   Easy   Link
1501   Countries You Can Safely Invest In   Medium   Link
1511   Customer Order Frequency   Easy   Link
1517   Find Users With Valid Emails   Easy   Link
1527   Patients With A Condition   Easy   Link
1532   The Most Recent Three Orders   Medium   Link
1543   Fix Product Name Format   Easy   Link
1549   The Most Recent Orders For Each Product   Medium   Link
1555   Bank Account Summary   Medium   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
1596   The Most Frequently Ordered Products For Each Customer   Medium   Link
1607   Sellers With No Sales   Easy   Link
1613   Find The Missing IDs   Medium   Link
1623   All Valid Triplets That Can Represent A Country   Easy   Link
1633   Percentage Of Users Attended A Contest   Easy   Link
1635   Hopper Company Queries I   Hard   Link
1645   Hopper Company Queries II   Hard   Link
1651   Hopper Company Queries III   Hard   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
1699   Number Of Calls Between Two Persons   Medium   Link
1709   Biggest Window Between Visits   Medium   Link
1715   Count Apples And Oranges   Medium   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
1747   Leetflex Banned Accounts   Medium   Link
1757   Recyclable And Low Fat Products   Easy   Link
1767   Find The Subtasks That Did Not Execute   Hard   Link
1777   Product’s Price For Each Store   Easy   Link
1783   Grand Slam Titles   Medium   Link
1789   Primary Department For Each Employee   Easy   Link
1795   Rearrange Products Table   Easy   Link
1809   Ad-Free Sessions Table   Easy   Link
1811   Find Interview Candidates   Medium   Link
1821   Find Customers With Positive Revenue this Year   Easy   Link
1831   Maximum Transaction Each Day   Medium   Link
1841   League Statistics   Medium   Link
1843   Suspicious Bank Accounts   Medium   Link
1853   Convert Date Format   Easy   Link
1867   Orders With Maximum Quantity Above Average   Medium   Link
1873   Calculate Special Bonus   Easy   Link
1875   Group Employees of the Same Salary   Medium   Link
1890   The Latest Login in 2020   Easy   Link
1892   Page Recommendations II   Hard   Link
1907   Count Salary Categories   Medium   Link
1917   Leetcodify Friends Recommendations   Hard   Link
1919   Leetcodify Similar Friends   Hard   Link
1934   Confirmation Rate   Medium   Link
1939   Users That Actively Request Confirmation Messages   Easy   Link
1949   Strong Friendship   Medium   Link
1951   All the Pairs With the Maximum Number of Common Followers   Medium   Link
1965   Employees With Missing Information   Easy   Link
1972   First and Last Call On the Same Day   Hard   Link
1978   Employees Whose Manager Left the Company   Easy   Link
1988   Find Cutoff Score for Each School   Medium   Link
1990   Count the Number of Experiments   Medium   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...