My collection of Leetcode problem solutions. https://leetcode.com/
Number | Problem | Category | Solution |
---|---|---|---|
217 | Contains Duplicate | Arrays & Hashing | python3 |
242 | Valid Anagram | Arrays & Hashing | python3 |
1 | Two Sum | Arrays & Hashing | java, python3 |
49 | Group Anagrams | Arrays & Hashing | python3 |
347 | Top K Frequent Elements | Arrays & Hashing | python3 |
238 | Product of Array Except Self | Arrays & Hashing | python3 |
36 | Valid Sudoku | Arrays & Hashing | python3 |
271 | Encode and Decode Strings | Arrays & Hashing | python3 |
128 | Longest Consecutive Sequence | Arrays & Hashing | python3 |
125 | Valid Palindrome | Two Pointers | python3 |
167 | Two Sum II | Two Pointers | python3 |
15 | 3Sum | Two Pointers | java, python3 |
11 | Container with Most Water | Two Pointers | java, python3 |
42 | Trapping Rain Water | Two Pointers | python3 |
121 | Best Time to Buy & Sell Stock | Sliding Window | python3 |
3 | Longest Substring Without Repeating Characters | Sliding Window | java, python3 |
424 | Longest Repeating Character Replacement | Sliding Window | python3 |
567 | Permutation in String | Sliding Window | python3 |
76 | Minimum Window Substring | Sliding Window | python3 |
239 | Sliding Window Maximum | Sliding Window | |
20 | Valid Parentheses | Stack | java, python3 |
155 | Min Stack | Stack | python3 |
150 | Evaluate Reverse Polish Notation | Stack | python3 |
22 | Generate Parentheses | Stack | java, python3 |
739 | Daily Temperatures | Stack | python3 |
853 | Car Fleet | Stack | python3 |
84 | Largest Rectangle in Histogram | Stack | python3 |
704 | Binary Search | Binary Search | python3 |
74 | Search a 2D Matrix | Binary Search | python3 |
875 | Koko Eating Bananas | Binary Search | python3 |
33 | Search Rotated Sorted Array | Binary Search | java, python3 |
153 | Find Minimum in Rotated Sorted Array | Binary Search | python3 |
981 | Time Based Key-Value Store | Binary Search | python3 |
4 | Find Median of Two Sorted Arrays | Binary Search | java |
206 | Reverse Linked List | Linked List | python3 |
21 | Merge Two Linked Lists | Linked List | java, python3 |
143 | Reorder List | Linked List | python3 |
19 | Remove Nth Node from End of List | Linked List | java, python3 |
138 | Copy List with Random Pointer | Linked List | python3 |
2 | Add Two Numbers | Linked List | java, python3 |
141 | Linked List Cycle | Linked List | python3 |
287 | Find the Duplicate Number | Linked List | python3 |
146 | LRU Cache | Linked List | python3 |
23 | Merge K Sorted Lists | Linked List | java, python3 |
25 | Reverse Nodes in K-Group | Linked List | |
226 | Invert Binary Tree | Trees | python3 |
104 | Maximum Depth of Binary Tree | Trees | python3 |
543 | Diameter of a Binary Tree | Trees | python3 |
110 | Balanced Binary Tree | Trees | python3 |
100 | Same Tree | Trees | python3 |
572 | Subtree of Another Tree | Trees | |
235 | Lowest Common Ancestor of a BST | Trees | python3 |
102 | Binary Tree Level Order Traversal | Trees | python3 |
199 | Binary Tree Right Side View | Trees | python3 |
1448 | Count Good Nodes in a Binary Tree | Trees | |
98 | Validate Binary Search Tree | Trees | |
230 | Kth Smallest Element in a BST | Trees | |
105 | Construct Tree from Preorder and Inorder Traversal | Trees | python3 |
124 | Binary Tree Max Path Sum | Trees | |
297 | Serialize and Deserialize Binary Tree | Trees | python3 |
208 | Implement Trie | Tries | |
211 | Design Add and Search Word Data Structure | Tries | |
212 | Word Search II | Tries | |
703 | Kth Largest Element in a Stream | Heap / Priority Queue | python3 |
1046 | Last Stone Weight | Heap / Priority Queue | python3 |
973 | K Closest Points to Origin | Heap / Priority Queue | python3 |
215 | Kth Largest Element in an Array | Heap / Priority Queue | python3 |
621 | Task Scheduler | Heap / Priority Queue | python3 |
355 | Design Twitter | Heap / Priority Queue | |
295 | Find Median from Data Stream | Heap / Priority Queue | |
78 | Subsets | Backtracking | python3 |
39 | Combination Sum | Backtracking | java, python3 |
46 | Permutations | Backtracking | java, python3 |
90 | Subsets II | Backtracking | python3 |
40 | Combination Sum II | Backtracking | java, python3 |
79 | Word Search | Backtracking | python3 |
131 | Palindrome Partitioning | Backtracking | python3 |
17 | Letter Combinations of a Phone Number | Backtracking | java, python3 |
51 | N-Queens | Backtracking | python3 |
200 | Number of Islands | Graphs | python3 |
133 | Clone Graph | Graphs | |
695 | Max Area of Island | Graphs | |
417 | Pacific Atlantic Waterflow | Graphs | |
130 | Surrounded Regions | Graphs | |
994 | Rotting Oranges | Graphs | |
286 | Walls and Gates | Graphs | |
207 | Course Schedule | Graphs | |
210 | Course Schedule II | Graphs | |
684 | Redundant Connection | Graphs | |
323 | Number of Connected Components in Graph | Graphs | |
261 | Graph Valid Tree | Graphs | |
127 | Word Ladder | Graphs | |
332 | Reconstruct Itinerary | Advanced Graphs | |
1584 | Min Cost to Connect all Points | Advanced Graphs | |
743 | Network Delay Time | Advanced Graphs | |
778 | Swim in Rising Water | Advanced Graphs | |
269 | Alien Dictionary | Advanced Graphs | |
787 | Cheapest Flights Within K Stops | Advanced Graphs | |
70 | Climbing Stairs | 1-D Dynamic Programming | java, python3 |
746 | Min Cost Climbing Stairs | 1-D Dynamic Programming | python3 |
198 | House Robber | 1-D Dynamic Programming | python3 |
213 | House Robber II | 1-D Dynamic Programming | python3 |
5 | Longest Palindromic Substring | 1-D Dynamic Programming | java, python3 |
647 | Palindromic Substrings | 1-D Dynamic Programming | python3 |
91 | Decode Ways | 1-D Dynamic Programming | python3 |
322 | Coin Change | 1-D Dynamic Programming | python3 |
152 | Maximum Product Subarray | 1-D Dynamic Programming | python3 |
139 | Word Break | 1-D Dynamic Programming | python3 |
300 | Longest Increasing Subsequence | 1-D Dynamic Programming | python3 |
416 | Partition Equal Subset Sum | 1-D Dynamic Programming | python3 |
62 | Unique Paths | 2-D Dynamic Programming | python3 |
1143 | Longest Common Subsequence | 2-D Dynamic Programming | python3 |
309 | Best Time to Buy/Sell Stock With Cooldown | 2-D Dynamic Programming | python3 |
518 | Coin Change II | 2-D Dynamic Programming | python3 |
494 | Target Sum | 2-D Dynamic Programming | python3 |
97 | Interleaving String | 2-D Dynamic Programming | python3 |
329 | Longest Increasing Path in a Matrix | 2-D Dynamic Programming | |
115 | Distinct Subsequences | 2-D Dynamic Programming | |
72 | Edit Distance | 2-D Dynamic Programming | |
312 | Burst Balloons | 2-D Dynamic Programming | |
10 | Regular Expression Matching | 2-D Dynamic Programming | java |
53 | Maximum Subarray | Greedy | java, python3 |
55 | Jump Game | Greedy | java, python3 |
45 | Jump Game II | Greedy | java, python3 |
134 | Gas Station | Greedy | python3 |
846 | Hand of Straights | Greedy | python3 |
1899 | Merge Triplets to Form Target Triplet | Greedy | python3 |
763 | Partition Labels | Greedy | python3 |
678 | Valid Parenthesis String | Greedy | python3 |
57 | Insert Interval | Intervals | python3 |
56 | Merge Intervals | Intervals | python3 |
435 | Non-Overlapping Intervals | Intervals | |
252 | Meeting Rooms | Intervals | |
253 | Meeting Rooms II | Intervals | |
1851 | Minimum Interval to Include Each Query | Intervals | |
48 | Rotate Image | Math & Geometry | java |
54 | Spiral Matrix | Math & Geometry | |
73 | Set Matrix Zeroes | Math & Geometry | |
202 | Happy Number | Math & Geometry | |
66 | Plus One | Math & Geometry | |
50 | Pow(x, n) | Math & Geometry | |
43 | Multiply Strings | Math & Geometry | |
2013 | Detect Squares | Math & Geometry | |
136 | Single Number | Bit Manipulation | |
191 | Number of 1 Bits | Bit Manipulation | |
338 | Counting Bits | Bit Manipulation | |
190 | Reverse Bits | Bit Manipulation | |
268 | Missing Number | Bit Manipulation | |
371 | Sum of Two Integers | Bit Manipulation | |
7 | Reverse Integer | Bit Manipulation | java |
Number | Problem | Category | Solution |
---|---|---|---|
16 | 3Sum Closest | Arrays & Hashing | java |
18 | 4Sum | Arrays & Hashing | java |
75 | Sort Colors | Arrays & Hashing | java, python3 |
147 | Insertion Sort List | Arrays & Hashing | java |
148 | Sort List | Arrays & Hashing | java |
169 | Majority Element | Arrays & Hashing | python3 |
216 | Combination Sum III | Arrays & Hashing | java, python3 |
224 | Basic Calculator | Arrays & Hashing | python3 |
34 | Find First and Last Position of Element in Sorted Array | Binary Search | java |
278 | First Bad Version | Binary Search | python3 |
24 | Swap Nodes in Pairs | Linked List | java |
876 | Middle of the Linked List | Linked List | python3 |
9 | Palindrome Number | Math | java |
13 | Roman to Integer | Math | java |
31 | Next Permutation | Math | java |
232 | Implement Queue using Stacks | Stack | python3 |
6 | Zigzag Conversion | String | java |
8 | String to Integer (atoi) | String | java |
12 | Integer to Roman | String | java |
14 | Longest Common Prefix | String | java |
409 | Longest Palindrome | String | java, python3 |
438 | Find All Anagrams in a String | String | python3 |
94 | Binary Tree Inorder Traversal | Tree | java |
236 | Lowest Common Ancestor of a Binary Tree | Tree | python3 |
1235 | Maximum Profit in Job Scheduling | 2-D Dynamic Programming | python3 |