/Leetcode

My Leetcode solutions

Primary LanguagePython

My Leetcode solutions

For most most of the Leetcode tasks I used Python.

Of course for the SQL and Bash scripting tasks I used the respective languages.

Here is a list of all the tasks along with their id and difficulty.

The format of each filename is: '{task_code}-{task_name_camelcase}.py'

The following table shows all the problems I have completed in Leetcode. The first column (Leetcode ID) has link to the respective problem page at Leetcode, while the 3rd column (Solution) links to my solution in this GitHub repo.

Leetcode Stats

Content

Leetcode ID Title Difficulty Solution
1 Two Sum Easy Python
2 Add Two Numbers Medium Python
7 Reverse integer Medium Python
8 String to integer (atoi) Medium Python
9 Palindrome Number Easy Python
11 Container With Most Water Medium Python
13 Roman to Integer Easy Python
14 Longest Common Prefix Easy Python
17 Letter Combinations of a Phone Number Medium Python
20 Valid Parentheses Easy Python
21 Merge Two Sorted Lists Easy Python
26 Remove Duplicates from Sorted Array Easy Python
27 Remove Element Easy Python
28 Implement strStr() Easy Python
34 Find First and Last Position of Element in Sorted Array Medium Python
35 Search Insert Position Easy Python
36 Valid Sudoku Medium Python
46 Permutations Medium Python
47 Permutations II Medium Python
48 Rotate Image Medium Python
49 Group Anagrams Medium Python
50 Pow(x, n) Medium Python
53 Maximum Subarray Medium Python
58 Length of Last Word Easy Python
66 Plus One Easy Python
67 Add Binary Easy Python
69 Sqrt(x) Easy Python
70 Climbing Stairs Easy Python
73 Set Matrix Zeroes Medium Python
74 Search a 2D Matrix Medium Python
75 Sort Colors Medium Python
77 Combinations Medium Python
78 Subsets Medium Python
83 Remove Duplicates from Sorted List Easy Python
94 Binary Tree Inorder Traversal Easy Python
100 Same Tree Easy Python
104 Maximum Depth of Binary Tree Easy Python
108 Convert Sorted Array to Binary Search Tree Easy Python
111 Minimum Depth of Binary Tree Easy Python
114 Flatten Binary Tree to Linked List Medium Python
118 Pascal's Triangle Easy Python
119 Pascal's Triangle II Easy Python
121 Best Time to Buy and Sell Stock Easy Python
125 Valid Palindrome Easy Python
136 Single Number Easy Python
141 Linked List Cycle Easy Python
142 Linked List Cycle II Medium Python
144 Binary Tree Preorder Traversal Easy Python
145 Binary Tree Postorder Traversal Easy Python
148 Sort List Medium Python
151 Reverse Words in a String Medium Python
153 Find Minimum in Rotated Sorted Array Medium Python
168 Excel Sheet Column Title Easy Python
169 Majority Element Easy Python
171 Excel Sheet Column Number Easy Python
175 Combine Two Tables Easy SQL
176 Second Highest Salary Medium SQL
177 Nth Highest Salary Medium SQL
178 Rank Scores Medium SQL
181 Employees Earning More Than Their Managers Easy SQL
182 Duplicate Emails Easy SQL
183 Customers Who Never Order Easy SQL
184 Department Highest Salary Medium SQL
187 Repeated DNA Sequences Medium Python
190 Reverse Bits Easy Python
191 Number of 1 Bits Easy Python
192 Word Frequency Medium Python
193 Valid Phone Numbers Easy Bash script
195 Tenth Line Easy Bash script
196 Delete Duplicate Emails Easy SQL
197 Rising Temperature Easy SQL
202 Happy Number Easy Python
206 Reverse Linked List Easy Python
215 Kth Largest Element in an Array Medium Python
216 Combination Sum III Medium Python
217 Contains Duplicate Easy Python
226 Invert Binary Tree Easy Python
231 Power of Two Easy Python
234 Palindrome Linked List Easy Python
237 Delete Node in a Linked List Easy Python
240 Search a 2D Matrix II Medium Python
242 Valid Anagram Easy Python
258 Add Digits Easy Python
268 Missing Number Easy Python
278 First Bad Version Easy Python
283 Move Zeroes Easy Python
287 Find The Duplicate Number Medium Python
290 Word Pattern Easy Python
303 Range Sum Query - Immutable Easy Python
319 Bulb Switcher Medium Python
326 Power of Three Easy Python
338 Counting Bits Easy Python
342 Power of Four Easy Python
344 Reverse String Easy Python
345 Reverse Vowels of a String Easy Python
347 Top K Frequent Elements Medium Python
349 Intersection of Two Arrays Easy Python
350 Intersection of Two Arrays II Easy Python
367 Valid Perfect Square Easy Python
374 Guess Number Higher or Lower Easy Python
378 Kth Smallest Element in a Sorted Matrix Medium Python
383 Ransom Note Easy Python
387 First Unique Character in a String Easy Python
389 Find the Difference Easy Python
412 Fizz Buzz Easy Python
414 Third Maximum Number Easy Python
434 Number of Segments in a String Easy Python
442 Find All Duplicates in an Array Medium Python
451 Sort Characters By Frequency Medium Python
461 Hamming Distance Easy Python
476 Number Complement Easy Python
485 Max Consecutive Ones Easy Python
496 Next Greater Element I Easy Python
500 Keyboard Row Easy Python
501 Find Mode in Binary Search Tree Easy Python
509 Fibonacci Number Easy Python
511 Game Play Analysis I Easy SQL
520 Detect Capital Easy Python
535 Encode and Decode TinyURL Medium Python
551 Student Attendance Record I Easy Python
557 Reverse Words in a String III Easy Python
559 Maximum Depth of N-ary Tree Easy Python
561 Array Partition Easy Python
566 Reshape the Matrix Easy Python
575 Distribute Candies Easy Python
584 Find Customer Referee Easy SQL
586 Customer Placing the Largest Number of Orders Easy SQL
589 N-ary Tree Preorder Traversal Easy Python
590 N-ary Tree Postorder Traversal Easy Python
593 Valid Square Medium Python
595 Big Countries Easy SQL
596 Classes More Than 5 Students Easy SQL
598 Range Addition II Easy Python
606 Construct String from Binary Tree Easy Python
607 Sales Person Easy SQL
608 Tree Node Medium SQL
620 Not Boring Movies Easy SQL
627 Swap Salary Easy SQL
628 Maximum Product of Three Numbers Easy Python
637 Average of Levels in Binary Tree Easy Python
648 Replace Words Medium Python
657 Robot Return to Origin Easy Python
692 Top K Frequent Words Medium Python
693 Binary Number with Alternating Bits Easy Python
700 Search in a Binary Search Tree Easy Python
704 Binary Search Easy Python
705 Design HashSet Easy Python
706 Design HashMap Easy Python
709 To Lower Case Easy Python
724 Find Pivot Index Easy Python
728 Self Dividing Numbers Easy Python
729 My Calendar I Medium Python
744 Find Smallest Letter Greater Than Target Easy Python
747 Largest Number At Least Twice of Others Easy Python
762 Prime Number of Set Bits in Binary Representation Easy Python
766 Toeplitz Matrix Easy Python
771 Jewels and Stones Easy Python
796 Rotate String Easy Python
804 Unique Morse Code Words Easy Python
806 Number of Lines To Write String Easy Python
819 Most Common Word Easy Python
821 Shortest Distance to a Character Easy Python
824 Goat Latin Easy Python
832 Flipping an Image Easy Python
836 Rectangle Overlap Easy Python
867 Transpose Matrix Easy Python
868 Binary Gap Easy Python
876 Middle of the Linked List Easy Python
884 Uncommon Words from Two Sentences Easy Python
905 Sort Array By Parity Easy Python
917 Reverse Only Letters Easy Python
922 Sort Array By Parity II Easy Python
933 Number of Recent Calls Easy Python
938 Range Sum of BST Easy Python
944 Delete Columns to Make Sorted Easy Python
961 N-Repeated Element in Size 2N Array Easy Python
965 Univalued Binary Tree Easy Python
976 Largest Perimeter Triangle Easy Python
977 Squares of a Sorted Array Easy Python
989 Add to Array-Form of Integer Easy Python
997 Find the Town Judge Easy Python
1009 Complement of Base 10 Integer Easy Python
1046 Last Stone Weight Easy Python
1047 Remove All Adjacent Duplicates In String Easy Python
1050 Actors and Directors Who Cooperated At Least Three Times Easy SQL
1051 Height Checker Easy Python
1084 Sales Analysis III Easy SQL
1108 Defanging an IP Address Easy Python
1114 Print in Order Easy Python
1137 N-th Tribonacci Number Easy Python
1141 User Activity for the Past 30 Days I Easy SQL
1148 Article Views I Easy SQL
1154 Day of the Year Easy Python
1158 Market Analysis I Medium SQL
1160 Find Words That Can Be Formed by Characters Easy Python
1179 Reformat Department Table Easy SQL
1185 Day of the Week Easy Python
1189 Maximum Number of Balloons Easy Python
1207 Unique Number of Occurrences Easy Python
1217 Minimum Cost to Move Chips to The Same Position Easy Python
1221 Split a String in Balanced Strings Easy Python
1232 Check If It Is a Straight Line Easy Python
1252 Cells with Odd Values in a Matrix Easy Python
1281 Subtract the Product and Sum of Digits of an Integer Easy Python
1282 Group the People Given the Group Size They Belong To Medium Python
1287 Element Appearing More Than 25% In Sorted Array Easy Python
1290 Convert Binary Number in a Linked List to Integer Easy Python
1295 Find Numbers with Even Number of Digits Easy Python
1299 Replace Elements with Greatest Element on Right Side Easy Python
1309 Decrypt String from Alphabet to Integer Mapping Easy Python
1313 Decompress Run-Length Encoded List Easy Python
1323 Maximum 69 Number Easy Python
1324 Print Words Vertically Medium Python
1325 Delete Leaves With a Given Value Medium Python
1337 The K Weakest Rows in a Matrix Easy Python
1338 Reduce Array Size to The Half Medium Python
1342 Number of Steps to Reduce a Number to Zero Easy Python
1346 Check If N and Its Double Exist Easy Python
1351 Count Negative Numbers in a Sorted Matrix Easy Python
1365 How Many Numbers Are Smaller Than the Current Number Easy Python
1374 Generate a String With Characters That Have Odd Counts Easy Python
1379 Find a Corresponding Node of a Binary Tree in a Clone of That Tree Easy Python
1380 Lucky Numbers in a Matrix Easy Python
1385 Find the Distance Value Between Two Arrays Easy Python
1387 Sort Integers by The Power Value Medium Python
1393 Capital Gain/Loss Medium SQL
1394 Find Lucky Integer in an Array Easy Python
1407 Top Travellers Easy SQL
1408 String Matching in an Array Easy Python
1431 Kids With the Greatest Number of Candies Easy Python
1436 Destination City Easy Python
1437 Check If All 1's Are at Least Length K Places Away Easy Python
1446 Consecutive Characters Easy Python
1450 Number of Students Doing Homework at a Given Time Easy Python
1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence Easy Python
1461 Check If a String Contains All Binary Codes of Size K Medium Python
1464 Maximum Product of Two Elements in an Array Easy Python
1470 Shuffle the Array Easy Python
1472 Design Browser History Medium Python
1475 Final Prices With a Special Discount in a Shop Easy Python
1476 Subrectangle Queries Medium Python
1480 Running Sum of 1d Array Easy Python
1484 Group Sold Products By The Date Easy SQL
1486 XOR Operation in an Array Easy Python
1491 Average Salary Excluding the Minimum and Maximum Salary Easy Python
1502 Can Make Arithmetic Progression From Sequence Easy Python
1507 Reformat Date Easy Python
1512 Number of Good Pairs Easy Python
1523 Count Odd Numbers in an Interval Range Easy Python
1527 Patients With a Condition Easy SQL
1528 Shuffle String Easy Python
1534 Count Good Triplets Easy Python
1539 Kth Missing Positive Number Easy Python
1550 Three Consecutive Odds Easy Python
1572 Matrix Diagonal Sum Easy Python
1576 Replace All ?'s to Avoid Consecutive Repeating Characters Easy Python
1581 Customer Who Visited but Did Not Make Any Transactions Easy SQL
1582 Special Positions in a Binary Matrix Easy Python
1587 Bank Account Summary II Easy SQL
1588 Sum of All Odd Length Subarrays Easy Python
1603 Design Parking System Easy Python
1608 Special Array With X Elements Greater Than or Equal X Easy Python
1614 Maximum Nesting Depth of the Parentheses Easy Python
1619 Mean of Array After Removing Some Elements Easy Python
1636 Sort Array by Increasing Frequency Easy Python
1646 Get Maximum in Generated Array Easy Python
1662 Check If Two String Arrays are Equivalent Easy Python
1667 Fix Names in a Table Easy SQL
1672 Richest Customer Wealth Easy Python
1678 Goal Parser Interpretation Easy Python
1684 Count the Number of Consistent Strings Easy Python
1688 Count of Matches in Tournament Easy Python
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers Medium Python
1693 Daily Leads and Partners Easy SQL
1704 Determine if String Halves Are Alike Easy Python
1716 Calculate Money in Leetcode Bank Easy Python
1720 Decode XORed Array Easy Python
1729 Find Followers Count Easy SQL
1732 Find the Highest Altitude Easy Python
1741 Find Total Time Spent by Each Employee Easy SQL
1748 Sum of Unique Elements Easy Python
1757 Recyclable and Low Fat Products Easy SQL
1768 Merge Strings Alternately Easy Python
1773 Count Items Matching a Rule Easy Python
1779 Find Nearest Point That Has the Same X or Y Coordinate Easy Python
1790 Check if One String Swap Can Make Strings Equal Easy Python
1791 Find Center of Star Graph Easy Python
1795 Rearrange Products Table Easy SQL
1796 Second Largest Digit in a String Easy Python
1805 Number of Different Integers in a String Easy Python
1812 Determine Color of a Chessboard Square Easy Python
1816 Truncate Sentence Easy Python
1817 Finding the Users Active Minutes Medium Python
1822 Sign of the Product of an Array Easy Python
1828 Queries on Number of Points Inside a Circle Medium Python
1832 Check if the Sentence Is Pangram Easy Python
1844 Replace All Digits with Characters Easy Python
1859 Sorting the Sentence Easy Python
1863 Sum of All Subset XOR Totals Easy Python
1873 Calculate Special Bonus Easy SQL
1876 Substrings of Size Three with Distinct Characters Easy Python
1880 Check if Word Equals Summation of Two Words Easy Python
1890 The Latest Login in 2020 Easy SQL
1909 Remove One Element to Make the Array Strictly Increasing Easy Python
1910 Remove All Occurrences of a Substring Medium Python
1913 Maximum Product Difference Between Two Pairs Easy Python
1920 Build Array from Permutation Easy Python
1925 Count Square Sum Triples Easy Python
1929 Concatenation of Array Easy Python
1941 Check if All Characters Have Equal Number of Occurrences Easy Python
1965 Employees With Missing Information Easy SQL
1967 Number of Strings That Appear as Substrings in Word Easy Python
1979 Find Greatest Common Divisor of Array Easy Python
2000 Reverse Prefix of Word Easy Python
2006 Count Number of Pairs With Absolute Difference K Easy Python
2011 Final Value of Variable After Performing Operations Easy Python
2032 Two Out of Three Easy Python
2037 Minimum Number of Moves to Seat Everyone Easy Python
2042 Check if Numbers Are Ascending in a Sentence Easy Python
2047 Number of Valid Words in a Sentence Easy Python
2053 Kth Distinct String in an Array Easy Python
2057 Smallest Index With Equal Value Easy Python
2079 Watering Plants Medium Python
2085 Count Common Words With One Occurrence Easy Python
2094 Finding 3-Digit Even Numbers Easy Python
2103 Rings and Rods Easy Python
2108 Find First Palindromic String in the Array Easy Python
2114 Maximum Number of Words Found in Sentences Easy Python
2119 A Number After a Double Reversal Easy Python
2124 Check if All A's Appears Before All B's Easy Python
2129 Capitalize the Title Easy Python
2133 Check if Every Row and Column Contains All Numbers Easy Python
2138 Divide a String Into Groups of Size k Easy Python
2148 Count Elements With Strictly Smaller and Greater Elements Easy Python
2149 Rearrange Array Elements by Sign Medium Python
2154 Keep Multiplying Found Values by Two Easy Python
2160 Minimum Sum of Four Digit Number After Splitting Digits Easy Python
2161 Partition Array According to Given Pivot Medium Python
2169 Count Operations to Obtain Zero Easy Python
2176 Count Equal and Divisible Pairs in an Array Easy Python
2180 Count Integers With Even Digit Sum Easy Python
2185 Counting Words With a Given Prefix Easy Python
2190 Most Frequent Number Following Key In an Array Easy Python
2194 Cells in a Range on an Excel Sheet Easy Python
2200 Find All K-Distant Indices in an Array Easy Python
2206 Divide Array Into Equal Pairs Easy Python
2215 Find the Difference of Two Arrays Easy Python
2221 Find Triangular Sum of an Array Medium Python
2235 Add Two Integers Easy Python
2236 Root Equals Sum of Children Easy Python
2239 Find Closest Number to Zero Easy Python
2243 Calculate Digit Sum of a String Easy Python
2248 Intersection of Multiple Arrays Easy Python
2255 Count Prefixes of a Given String Easy Python
2264 Largest 3-Same-Digit Number in String Easy Python
2269 Find the K-Beauty of a Number Easy Python
2273 Find Resultant Array After Removing Anagrams Easy Python
2278 Percentage of Letter in String Easy Python
2283 Check if Number Has Equal Digit Count and Digit Value Easy Python
2299 Strong Password Checker II Easy Python
2303 Calculate Amount Paid in Taxes Easy Python
2309 Greatest English Letter in Upper and Lower Case Easy Python
2315 Count Asterisks Easy Python
2319 Check if Matrix Is X-Matrix Easy Python
2325 Decode the Message Easy Python
2331 Evaluate Boolean Binary Tree Easy Python
2335 Minimum Amount of Time to Fill Cups Easy Python
2341 Maximum Number of Pairs in Array Easy Python
2347 Best Poker Hand Easy Python
2351 First Letter to Appear Twice Easy Python
2352 Equal Row and Column Pairs Medium Python
2357 Make Array Zero by Subtracting Equal Amounts Easy Python
2363 Merge Similar Items Easy Python
2367 Number of Arithmetic Triplets Easy Python
2396 Strictly Palindromic Number Medium Python
2404 Most Frequent Even Element Easy Python
2413 Smallest Even Multiple Easy Python
2442 Count Number of Distinct Integers After Reverse Operations Medium Python
2469 Convert the Temperature Easy Python
2535 Difference Between Element Sum and Digit Sum of an Array Easy Python