My solutions to LeetCode problems in Python, organized by pattern.
| Difficulty | Solved |
|---|---|
| Easy | 25 |
| Medium | 30 |
| Hard | 5 |
| Total | 60 |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 1 | Two Sum | Easy | Python |
| 217 | Contains Duplicate | Easy | Python |
| 49 | Group Anagrams | Medium | Python |
| 347 | Top K Frequent Elements | Medium | Python |
| 238 | Product of Array Except Self | Medium | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 125 | Valid Palindrome | Easy | Python |
| 15 | 3Sum | Medium | Python |
| 11 | Container With Most Water | Medium | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 121 | Best Time to Buy/Sell Stock | Easy | Python |
| 3 | Longest Substring Without Repeating | Medium | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 704 | Binary Search | Easy | Python |
| 33 | Search in Rotated Sorted Array | Medium | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 206 | Reverse Linked List | Easy | Python |
| 21 | Merge Two Sorted Lists | Easy | Python |
| 141 | Linked List Cycle | Easy | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 226 | Invert Binary Tree | Easy | Python |
| 104 | Maximum Depth of Binary Tree | Easy | Python |
| 102 | Level Order Traversal | Medium | Python |
| 98 | Validate BST | Medium | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 703 | Kth Largest in Stream | Easy | Python |
| 215 | Kth Largest in Array | Medium | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 200 | Number of Islands | Medium | Python |
| 133 | Clone Graph | Medium | Python |
| 207 | Course Schedule | Medium | Python |
| # | Problem | Difficulty | Solution |
|---|---|---|---|
| 70 | Climbing Stairs | Easy | Python |
| 198 | House Robber | Medium | Python |
| 322 | Coin Change | Medium | Python |
- Understand — Read 3 times, write examples by hand
- Brute Force — Get something working, even O(n²)
- Optimize — Identify the pattern, reduce complexity
- Code — Clean solution with comments on approach
- Test — Edge cases: empty, single element, negatives
| Pattern | Key Insight |
|---|---|
| Two Pointers | Start from both ends, move inward |
| Sliding Window | Expand/contract window, track state |
| Binary Search | Find search space, eliminate half |
| BFS/DFS | Queue for shortest, stack for exhaustion |
| Top-K Elements | Heap of size K |
| DP | Memoization → tabulation |
| Backtracking | Choose → explore → un-choose |