Python solution for LeetCode
As a non-CS background programmer. LeetCode is a great website to sharpen my programming/problem-solving skills. Of course, not all solutions here are optimal, but I will add detailed explaination to each of them.
- Array
- Binary Search
- Breadth-First Search
- Depth-First Search
- Dynamic Programming
- Graph
- Hash Table
- Linked List
- Math
- Queue
- Recursion
- String
- Stack
- Tree
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0004 | Median of Two Sorted Arrays | Python | Hard | ||
0033 | Search in Rotated Sorted Array | Python | Medium | ||
0034 | Find First and Last Position of Element in Sorted Array | Python Java |
Medium | ||
0069 | Sqrt(x) | Python | Easy | ||
0074 | Search a 2D Matrix | Python | Medium | ||
0081 | Search in Rotated Sorted Array II | Python | Medium | ||
0162 | Find Peak Element | Python | Medium | ||
0240 | Search a 2D Matrix II | Python | Medium | ||
0295 | Find Median from Data Stream | Python | Hard | ||
0367 | Valid Perfect Square | Python | Easy | ||
0436 | Find Right Interval | Python | Medium | ||
0540 | Single Element in a Sorted Array | Python Java |
Medium | ||
0658 | Find K Closest Elements | Python Java |
Medium | Customized Sorting | |
1283 | Find the Smallest Divisor Given a Threshold | Python | Medium |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0133 | Clone Graph | Python | Medium | BFS/DFS | |
0207 | Course Schedule | Python | Medium | Topological Ordering | |
0210 | Course Schedule II | Python | Medium | Topological Ordering | |
0310 | Minimum Height Trees | Python | Medium | Topological Ordering | |
0417 | Pacific Atlantic Water Flow | Python | Medium | BFS/DFS | |
0542 | 01 Matrix | Python Java |
Medium | BFS | |
0752 | Open the Lock | Python Java |
Medium | BFS | |
0994 | Rotting Oranges | Python | Medium | BFS | |
1091 | Shortest Path in Binary Matrix | Python | Medium | BFS | |
1302 | Deepest Leaves Sum | Python Java |
Medium | BFS/DFS | |
1306 | Jump Game III | Python Java |
Medium | BFS/DFS |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0332 | Reconstruct Itinerary | Python | Medium | DFS | |
0797 | All Paths From Source to Target | Python Java |
Medium | BFS/DFS | |
0863 | All Nodes Distance K in Binary Tree | Python | Medium |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0001 | Two Sum | Python | Easy | ||
0049 | Group Anagrams | Python Java |
Medium | ||
0076 | Minimum Window Substring | Python | Hard | Sliding Window | |
0146 | LRU Cache | Python | Medium | ||
0290 | Word Pattern | Python | Easy | ||
0299 | Bulls and Cows | Python | Easy | ||
0347 | Top K Frequent Elements | Python | Medium | Heap | |
0460 | LFU Cache | Python | Hard | ||
0554 | Brick Wall | Python Java |
Medium | ||
0609 | Find Duplicate File in System | Python Java |
Medium | ||
0677 | Map Sum Pairs | Python Java |
Medium | ||
0692 | Top K Frequent Words | Python | Medium | Customized Sort | |
0953 | Verifying an Alien Dictionary | Python | Easy | Customized Sort | |
0954 | Array of Doubled Pairs | Python Java |
Medium | ||
0966 | Vowel Spellchecker | Python | Medium |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0002 | Add Two Numbers | Python | Medium | ||
0021 | Merge Two Sorted Lists | Python | Easy | ||
0023 | Merge k Sorted Lists | Python | Hard | ||
0024 | Swap Nodes in Pairs | Python | Medium | ||
0061 | Rotate List | Python | Medium | ||
0086 | Partition List | Python Java |
Medium | ||
0092 | Reverse Linked List II | Python Java |
Medium | ||
0138 | Copy List with Random Pointer | Python | Medium | ||
0148 | Sort List | Python | Medium | ||
0141 | Linked List Cycle | Python | Easy | Two Pointer | |
0142 | Linked List Cycle II | Python | Medium | Two Pointer | |
0143 | Reorder List | Python | Medium | ||
0147 | Insertion Sort List | Python | Medium | ||
0206 | Reverse Linked List | Python Java |
Easy | ||
0234 | Palindrome Linked List | Python | Easy | ||
0328 | Odd Even Linked List | Python Java |
Medium | ||
0382 | Linked List Random Node | Python | Medium | ||
0445 | Add Two Numbers II | Python | Medium |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0478 | Generate Random Point in a Circle | Python | Medium | ||
1344 | Angle Between Hands of a Clock | Python | Medium | ||
1492 | The kth Factor of n | Python | Medium | ||
1551 | Minimum Operations to Make Array Equal | Python | Medium |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0622 | Design Circular Queue | Python | Medium | ||
0641 | Design Circular Deque | Python | Medium | ||
0933 | Number of Recent Calls | Python | Easy | ||
0948 | Bag of Tokens | Python | Medium | ||
1649 | Jump Game VI | Python Java |
Medium | Deque |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0046 | Permutations | Python | Medium | Backtracking/DFS | |
0047 | Permutations II | Python | Medium | Backtracking/DFS | |
0050 | Pow(x,n) | Python | Medium | ||
0077 | Combinations | Python | Medium | Backtracking/DFS | |
0967 | Numbers With Same Consecutive Differences | Python | Medium | BFS/DFS/Backtracking | |
1286 | Iterator for Combination | Python | Medium | Backtracking/DFS |
# | Title | Solution | Difficulty | Tag | Note |
---|---|---|---|---|---|
0056 | Merge Intervals | Python | Medium | ||
0071 | Simplify Path | Python | Medium | ||
0084 | Largest Rectangle in Histogram | Python | Hard | Monotonic stack | |
0150 | Evaluate Reverse Polish Notation | Python Java |
Medium | ||
0155 | Min Stack | Python Java |
Easy | ||
0232 | Implement Queue using Stacks | Java | Easy | ||
0316 | Remove Duplicate Letters | Python | Medium | ||
0394 | Decode String | Python | Medium | ||
0456 | 132 Pattern | Python | Medium | ||
0496 | Next Greater Element I | PythonJava | Easy | ||
0503 | Next Greater Element II | Python | Medium | ||
0735 | Asteroid Collision | Python | Medium | ||
0739 | Daily Temperatures | Python | Medium | ||
0895 | Maximum Frequency Stack | Python | Hard | ||
0921 | Minimum Add to Make Parentheses Valid | Python | Medium | ||
0946 | Validate Stack Sequences | Python | Medium | ||
1209 | Remove All Adjacent Duplicates in String II | Python Java |
Medium | ||
1249 | Minimum Remove to Make Valid Parentheses | Python | Medium | ||
1288 | Remove Covered Intervals | Python | Medium | Customized Sort | |
1673 | Find the Most Competitive Subsequence | Python | Medium |