Skip to content

xiaoqqchen/LeetCode-1

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LeetCode

Up to date (2015-09-06), there are 260 Algorithms / 13 Database / 4 Shell questions on LeetCode Online Judge. The number of questions is increasing recently. Here is the classification of all 277 questions. For more questions and solutions, you can see my LintCode repository. I'll keep updating for full summary and better solutions. Stay tuned for updates. (Notes: "πŸ“–" means you need to subscribe to LeetCode premium membership for the access to premium questions. )


Algorithms

Database

Shell


##Bit Manipulation

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 136 | Single Number | Python | O(n) | O(1) | Medium || 137 | Single Number II | Python | O(n) | O(1) | Medium || 190 | Reverse Bits | Python | O(n) | O(1) | Easy || 191 |Number of 1 Bits | Python | O(m) | O(1) | Easy || 201 | Bitwise AND of Numbers Range | Python | O(1) | O(1) | Medium || 231 | Power of Two | C++ Python | O(1) | O(1) | Easy | LintCode | 260 | Single Number III | C++ Python | O(n) | O(1) | Medium || 268| Missing Number | C++ Python | O(n) | O(1) | Medium | LintCode ||


##Array

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 15 | 3 Sum | Python | O(n^2) | O(1) | Medium || 16 | 3 Sum Closest | Python| O(n^2) | O(1) | Medium || 26 | Remove Duplicates from Sorted Array| Python | O(n) | O(1) | Easy || 27 | Remove Element | Python | O(n) | O(1) | Easy || 31 | Next Permutation| Python | O(n) | O(1) | Medium || Tricky 41 | First Missing Positive| Python | O(n) | O(1) | Hard || Tricky 48 | Rotate Image | Python | O(n^2) | O(1) | Medium || 54 | Spiral Matrix | Python | O(m * n) | O(1) | Medium || 59 | Spiral Matrix II | Python | O(m * n) | O(1) | Medium || 66 | Plus One | Python | O(n) | O(1) | Easy || 73 | Set Matrix Zeroes | Python | O(m * n) | O(1) | Medium || 80 | Remove Duplicates from Sorted Array II| Python | O(n) | O(1) | Medium || 118 | Pascal's Triangle| Python | O(n^2) | O(n) | Easy || 119 | Pascal's Triangle II| Python | O(n^2) | O(n) | Easy || 121 | Best Time to Buy and Sell Stock| Python | O(n) | O(1) | Medium || 128 | Longest Consecutive Sequence| Python | O(n) | O(n) | Hard || Tricky 157 | Read N Characters Given Read4 | Python | O(n) | O(1) | Easy |πŸ“–| 158 | Read N Characters Given Read4 II - Call multiple times | Python | O(n) | O(1) | Hard |πŸ“–| 163 | Missing Ranges| Python | O(n) | O(1) | Medium | πŸ“– | 169 | Majority Element | Python | O(n) | O(1) | Easy | 189 | Rotate Array | Python | O(n) | O(1) | Easy || 209 | Minimum Size Subarray Sum | [Python] (./Python/minimum-size-subarray-sum.py) | O(n) | O(1) | Medium | | Binary Search 215 | Kth Largest Element in an Array | [C++] (./C++/kth-largest-element-in-an-array.cpp) [Python] (./Python/kth-largest-element-in-an-array.py)| O(n) | O(1) | Medium | EPI| 228 | Summary Ranges | [C++] (./C++/summary-ranges.cpp) [Python] (./Python/summary-ranges.py)| O(n) | O(1) | Easy | | 229 | Majority Element II | C++ Python | O(n) | O(1) | Medium | | 238 | Product of Array Except Self | C++ Python | O(n) | O(1) | Medium | LintCode | 240 | Search a 2D Matrix II | C++ Python | O(m + n) | O(1) | Medium | EPI, LintCode | 243| Shortest Word Distance | C++ Python | O(n) | O(1) | Easy |πŸ“–|| 245| [Shortest Word Distance III](https://leetcode.com/problems/shortest-word-distance III/) | C++ Python | O(n) | O(1) | Medium |πŸ“–|| 251| Flatten 2D Vector | C++ Python | O(1) | O(1) | Medium |πŸ“–|| 277| Find the Celebrity | C++ Python | O(n) | O(1) | Medium |πŸ“–, EPI ||


##String

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 5| Longest Palindromic Substring | Python | O(n) | O(n) | Medium || Manacher's Algorithm 6| ZigZag Conversion | Python | O(n) | O(1) | Easy || 8| String to Integer (atoi) | Python | O(n) | O(1) | Easy || 14| Longest Common Prefix | Python | O(n1 + n2 + ...) | O(1) | Easy || 28| Implement strStr() | Python | O(n + m) | O(m) | Easy || KMP Algorithm 38| Count and Say | Python| O(n * 2^n) | O(2^n) | Easy || 43| Multiply Strings | Python | O(m * n) | O(m + n) | Medium || 58| Length of Last Word | Python | O(n) | O(1) | Easy || 67| Add Binary | Python | O(n) | O(1) | Easy || 68| Text Justification | Python | O(n) | O(1) | Hard || 125| Valid Palindrome | Python | O(n) | O(1) | Easy || 151| Reverse Words in a String | Python | O(n) | O(n) | Medium || 161| One Edit Distance | Python | O(m + n) | O(1) | Medium |πŸ“–| 165| Compare Version Numbers | Python | O(n) | O(1) | Easy || 186| Reverse Words in a String II | Python | O(n) | O(1) | Medium | πŸ“– | 205| Isomorphic Strings | Python | O(n) | O(1) | Easy ||
214| Shortest Palindrome | C++ Python | O(n) | O(n) | Hard || KMP Algorithm Manacher's Algorithm 271| Encode and Decode Strings | C++ Python | O(n) | O(1) | Medium | πŸ“– | 273| Integer to English Words | C++ Python | O(logn) | O(1) | Medium | |


##Linked List

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 2| Add Two Numbers | Python | O(n) | O(1) | Medium || 24| Swap Nodes in Pairs| Python | O(n) | O(1) | Medium || 25| Reverse Nodes in k-Group| Python | O(n) | O(1) | Hard || 61| Rotate List| Python | O(n) | O(1) | Medium ||
82| Remove Duplicates from Sorted List II| Python | O(n) | O(1) | Medium || 83| Remove Duplicates from Sorted List| Python | O(n) | O(1) | Easy || 92| Reverse Linked List II| Python | O(n) | O(1) | Medium || 138| Copy List with Random Pointer | Python | O(n) | O(1) | Hard || 160| Intersection of Two Linked Lists| Python | O(m + n) | O(1) | Easy || 203| Remove Linked List Elements| Python | O(n) | O(1) | Easy || 206| Reverse Linked List| Python | O(n) | O(1) | Easy || 234| Palindrome Linked List| C++ Python | O(n) | O(1) | Easy || 237| Delete Node in a Linked List| C++ Python | O(1) | O(1) | Easy | LintCode | 242| Valid Anagram| C++ Python | O(n) | O(1) | Easy | LintCode |


##Stack

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 20| Valid Parentheses| Python | O(n) | O(n) | Easy || 32| Longest Valid Parentheses| Python | O(n) | O(1) | Hard || 71| Simplify Path| Python | O(n) | O(n) | Medium || 101| Symmetric Tree| Python | O(n) | O(h) | Easy || 150| Evaluate Reverse Polish Notation| Python| O(n)| O(n)| Medium || 155| Min Stack | Python | O(n) | O(1) | Easy || 173| Binary Search Tree Iterator | Python | O(1)| O(h)| Medium ||
224| Basic Calculator | C++ Python | O(n)| O(n)| Medium || 227| Basic Calculator II | C++ Python | O(n)| O(n)| Medium || 232| Implement Queue using Stacks | C++ Python | O(1), amortized| O(n)| Easy | EPI, LintCode | 255| Verify Preorder Sequence in Binary Search Tree | C++ Python | O(n)| O(1)| Medium |πŸ“–|| 272| Closest Binary Search Tree Value II | C++ Python | O(h + k)| O(h)| Hard |πŸ“–||


##Queue

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 239| Sliding Window Maximum| C++ Python | O(n) | O(k) | Hard | EPI, LintCode |


##Heap

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 23| Merge k Sorted Lists | Python | O(nlogk)| O(k)| Hard || 264| Ugly Number II | C++ Python | O(n) | O(1) | Medium | CTCI, LintCode | BST, Heap |


##Tree

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 94 | Binary Tree Inorder Traversal | Python | O(n)| O(1)| Medium || Morris Traversal | 99 | Recover Binary Search Tree | Python | O(n)| O(1)| Hard || Morris Traversal 144 | Binary Tree Preorder Traversal | Python | O(n)| O(1)| Medium || Morris Traversal 145 | Binary Tree Postorder Traversal | Python | O(n)| O(1)| Hard || Morris Traversal 208 | Implement Trie (Prefix Tree) | Python | O(n) | O(1) | Medium || Trie 211 | Add and Search Word - Data structure design | C++ Python | O(min(n, h)) | O(min(n, h)) | Medium || Trie, DFS 212| Word Search II | C++ Python | O(m * n * l) | O(l) | Hard | LintCode | Trie, DFS 226| Invert Binary Tree | C++ Python | O(n) | O(h), O(w) | Easy ||


##Hash Table

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 1| Two Sum | Python | O(n) | O(n) | Medium || 3| Longest Substring Without Repeating Characters | Python | O(n) | O(1) | Medium || 18| 4 Sum |Python | O(n^2 * p) | O(n^2 * p) | Medium || 30| Substring with Concatenation of All Words | Python | O(m * n * k) | O(n * k) | Hard || 36| Valid Sudoku | Python | O(n^2) | O(n) | Easy || 49| Anagrams | Python | O(n) | O(n) | Medium || 76| Minimum Window Substring | Python | O(n) | O(k) | Hard || 149| Max Points on a Line | Python | O(n^2) | O(n) | Hard || 159| Longest Substring with At Most Two Distinct Characters| Python | O(n^2) | O(1) | Hard |πŸ“–| 170| Two Sum III - Data structure design | Python | O(n) | O(n) | Easy | πŸ“– | 187| Repeated DNA Sequences | Python | O(n) | O(n) | Medium || 202| Happy Number | Python | O(k) | O(k) | Easy || 204| Count Primes | Python | O(n) | O(n) | Easy || 217| Contains Duplicate | C++ Python | O(n) | O(n) | Easy || 219| Contains Duplicate II | C++ Python | O(n) | O(n) | Easy || 244| Shortest Word Distance II | C++ Python | ctor: O(n), lookup: O(a + b) | O(n) | Medium |πŸ“–|| 246| Strobogrammatic Number | C++ Python | O(n) | O(1) | Easy |πŸ“–|| 249| Group Shifted Strings | C++ Python | O(nlogn) | O(n) | Easy |πŸ“–|| 266| Palindrome Permutation | C++ Python | O(n) | O(1) | Easy |πŸ“–||


##Data Structure

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 146| LRU Cache | Python | O(1) | O(n) | Hard || 225| Implement Stack using Queues | C++ Python | Push: O(n), Pop: O(1), Top: O(1) | O(n) | Medium ||


##Math

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 7| Reverse Integer | Python | O(logn) | O(1) | Easy || 9| Palindrome Number | Python | O(1) | O(1) | Easy || 12| Integer to Roman | Python | O(n) | O(1) | Medium || 13| Roman to Integer | Python | O(n) | O(1) | Easy || 29| Divide Two Integers | Python | O(logn) | O(1) | Medium || 60| Permutation Sequence | Python | O(n^2) | O(n) | Medium || Cantor Ordering 65| Valid Number | Python | O(n) | O(1) | Hard || Automata 89| Gray Code | Python | O(2^n) | O(1) | Medium || 166| Fraction to Recurring Decimal | Python | O(logn) | O(1) | Medium || 168| Excel Sheet Column Title | Python | O(logn) | O(1) | Easy || 171| Excel Sheet Column Number | Python | O(n) | O(1) | Easy || 172| Factorial Trailing Zeroes | Python | O(logn) | O(1) | Easy || 223| Rectangle Area | C++ Python | O(1) | O(1) | Easy || 233| Number of Digit One | C++ Python | O(logn) | O(1) | Medium | CTCI, LintCode| 248| Strobogrammatic Number III | C++ Python | O(5^(n/2)) | O(n) | Hard |πŸ“–|| 258| Add Digits | C++ Python | O(1) | O(1) | Easy ||| 263| Ugly Number | C++ Python | O(logn) | O(1) | Easy |||


##Sort

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 21| Merge Two Sorted Lists| Python | O(n) | O(1) | Easy || 56| Merge Intervals| Python | O(nlogn) | O(1) | Hard || 57| Insert Interval| Python | O(n) | O(1) | Hard || 75| Sort Colors | Python | O(n) | O(1) | Medium || 88| Merge Sorted Array| Python | O(n) | O(1) | Easy || 147| Insertion Sort List|Python | O(n^2) | O(1) | Medium || 148| Sort List | Python | O(nlogn) | O(logn) | Medium || 164| Maximum Gap | Python| O(n) | O(n) | Hard || Tricky 179| Largest Number | Python | O(nlogn) | O(1) | Medium || 218| The Skyline Problem | C++ Python | O(nlogn) | O(n) | Hard || Sort, BST| 252| Meeting Rooms | C++ Python | O(nlogn) | O(n) | Easy |πŸ“–| | 253| Meeting Rooms II | C++ Python | O(nlogn) | O(n) | Medium |πŸ“–| | 274| H-Index | C++ Python | O(n) | O(n) | Medium || Counting Sort |


##Two Pointers

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 19| Remove Nth Node From End of List| Python | O(n) | O(1) | Easy || 86| Partition List| Python | O(n) | O(1) | Medium || 141| Linked List Cycle| Python | O(n) | O(1) | Medium || 142| Linked List Cycle II| Python | O(n) | O(1) | Medium || 143| Reorder List| Python | O(n) | O(1) | Medium ||
167| Two Sum II - Input array is sorted | Python | O(n) | O(1) | Medium | πŸ“– | 259 | 3Sum Smaller | C++ Python | O(n^2) | O(1) | Medium | πŸ“–, LintCode |


##Brute Force Search

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 17| Letter Combinations of a Phone Number| Python | O(n * 4^n) | O(n) | Medium || 46| Permutations| Python | O(n * n!) | O(n) | Medium || 47| Permutations II| Python | O(n * n!) | O(n) | Hard || 78| Subsets | Python | O(n * 2^n) | O(1) | Medium || 90| Subsets II | Python | O(n * 2^n) | O(1) | Medium || 267| Palindrome Permutation II | C++ Python | O(n * n!) | O(n) | Medium |πŸ“–||


##Divide and Conquer

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 95| Unique Binary Search Trees II | Python | O(4^n / n^(3/2) | O(4^n / n^(3/2) | Medium || 98| Validate Binary Search Tree|Python| O(n) | O(1) | Medium || 100| Same Tree |Python | O(n) | O(h) | Easy || 104| Maximum Depth of Binary Tree|Python| O(n) | O(h) | Easy || 105| Construct Binary Tree from Preorder and Inorder Traversal | Python | O(n) | O(n) | Medium || 106| Construct Binary Tree from Inorder and Postorder Traversal | Python | O(n) | O(n) | Medium || 108| Convert Sorted Array to Binary Search Tree | Python | O(n) | O(logn) | Medium || 109| Convert Sorted List to Binary Search Tree | Python | O(n) | O(logn) | Medium || 110| Balanced Binary Tree | Python | O(n)| O(h) | Easy || 111| Minimum Depth of Binary Tree|Python| O(n) | O(h) | Easy || 114| Flatten Binary Tree to Linked List|Python| O(n) | O(h) | Medium || 116| Populating Next Right Pointers in Each Node|Python| O(n) | O(1) | Medium || 124| Binary Tree Maximum Path Sum| Python | O(n)| O(h)| Hard ||
129| Sum Root to Leaf Numbers | Python | O(n) | O(h) | Medium || 156| Binary Tree Upside Down | Python | O(n) | O(1) | Medium |πŸ“–| 241| Different Ways to Add Parentheses | C++ Python | O(n * 4^n / n^(3/2)) | O(n * 4^n / n^(3/2)) | Medium ||


##Binary Search

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 4| Median of Two Sorted Arrays | Python | O(log(m + n)) | O(1) | Hard || 33| Search in Rotated Sorted Array | Python | O(logn) | O(1) | Hard || 34| Search for a Range | Python | O(logn) | O(1) | Medium || 35| Search Insert Position | Python | O(logn) | O(1) | Medium || 50| Pow(x, n) | Python | O(logn) | O(logn) | Medium || 69| Sqrt(x) | Python | O(logn) | O(1) | Medium || 74| Search a 2D Matrix | Python | O(logm + logn) | O(1) | Medium || 81| Search in Rotated Sorted Array II | Python | O(logn) | O(1) | Medium || 153| Find Minimum in Rotated Sorted Array | Python | O(logn) | O(1) | Medium || 154| Find Minimum in Rotated Sorted Array II | Python | O(logn) ~ O(n) | O(1) | Hard || 162| Find Peak Element | Python | O(logn) | O(1) | Medium || 222| Count Complete Tree Nodes | C++ Python | O((logn)^2) | O(1) | Medium || 275| H-Index II | C++ Python | O(logn) | O(1) | Medium || Binary Search |

-- ##Binary Search Tree

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 220| Contains Duplicate III | C++ Python | O(nlogk) | O(k) | medium || 230 | Kth Smallest Element in a BST | C++ Python | O(max(h, k)) | O(min(h, k)) | Medium || 235 | Lowest Common Ancestor of a Binary Search Tree | C++ Python | O(h) | O(1) | Easy | EPI | 270| Closest Binary Search Tree Value| C++ Python | O(h) | O(1) | Easy | πŸ“– |


##Breadth-First Search

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 102| Binary Tree Level Order Traversal| Python| O(n)| O(n)| Easy || 107| Binary Tree Level Order Traversal II| Python | O(n)| O(n)| Easy || 103| Binary Tree Zigzag Level Order Traversal| Python | O(n)| O(n)| Medium ||
117| Populating Next Right Pointers in Each Node II|Python| O(n) | O(1) | Hard || 127| Word Ladder|Python | O(n * d) | O(d) | Medium || 130| Surrounded Regions|Python| O(m * n) | O(m + n) | Medium || 133| Clone Graph| Python | O(n) | O(n) | Medium || 207| Course Schedule| Python | O(|V| + |E|) | O(|E|) | Medium || Topological Sort | 210| Course Schedule II| Python | O(|V| + |E|) | O(|E|) | Medium || Topological Sort | 261| Graph Valid Tree| C++ Python | O(|V| + |E|) | O(|V|) | Medium | πŸ“– | 269| Alien Dictionary | C++ Python | O(n) | O(1) | Hard |πŸ“–| Topological Sort, BFS, DFS |


##Depth-First Search

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 22| Generate Parentheses| Python| O(4^n / n^(3/2)) | O(n) | Medium || 37| Sudoku Solver | Python | O((9!)^9) | O(1) | Hard || 39| Combination Sum| Python | O(k * n^k) | O(k) | Medium || 40| Combination Sum II| Python| O(k * C(n, k))| O(k) | Medium || 51| N-Queens | Python | O(n!) | O(n) | Hard || 52| N-Queens-II | Python | O(n!) | O(n) | Hard || 77| Combinations | Python | O(n!) | O(n) | Medium || 79| Word Search | Python | O(m * n * l) | O(l) | Medium || 93| Restore IP Addresses | Python | O(n^m) ~ O(3^4) | O(n * m) ~ O(3 * 4) | Medium || 112| Path Sum | Python | O(n) | O(h) | Easy || 113| Path Sum II | Python | O(n) | O(h) | Medium || 131| Palindrome Partitioning | Python | O(n^2) ~ O(2^n) | O(n^2) | Medium || 199| Binary Tree Right Side View | Python | O(n) | O(h) | Medium || 200| Number of Islands | Python | O(m * n) | O(m * n)| Medium || 216| Combination Sum III| C++ Python | O(k * C(n, k)) | O(k) | Medium || 236 | Lowest Common Ancestor of a Binary Tree | C++ Python | O(h) | O(h) | Medium | EPI | 247| Strobogrammatic Number II | C++ Python | O(n^2 * 5^(n/2)) | O(n) | Medium |πŸ“–|| 250| Count Univalue Subtrees | C++ Python | O(n) | O(h) | Medium |πŸ“–|| 254| Factor Combinations | C++ Python | O(nlogn) | O(logn) | Medium |πŸ“–|| 257| Binary Tree Paths | C++ Python | O(n * h) | O(h) | Easy |||


##Dynamic Programming

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 10| Regular Expression Matching | Python | O(m * n) | O(n) | Hard || 53| Maximum Subarray|Python| O(n) | O(1) | Medium || 62| Unique Paths | Python| O(m * n) | O(m + n) | Medium || 63| Unique Paths II | Python | O(m * n) | O(m + n) | Medium || 64| Minimum Path Sum|Python| O(m * n) | O(m + n) | Medium || 70| Climbing Stairs| Python | O(n) | O(1) | Easy || 72| Edit Distance|Python| O(m * n) | O(m + n) | Hard || 85| Maximal Rectangle|Python| O(n^2) | O(n) | Hard || 87| Scramble String | Python | O(n^4) | O(n^3) | Hard || 91| Decode Ways | Python| O(n) | O(1) | Medium || 96| Unique Binary Search Trees | Python | O(n^2) | O(n) | Medium || 97| Interleaving String|Python| O(m * n) | O(m + n) | Hard || 115| Distinct Subsequences|Python| O(n^2) | O(n) | Hard || 120| Triangle | Python | O(m * n) | O(n) | Medium || 123| Best Time to Buy and Sell Stock III | Python | O(n) | O(1) | Hard || 132| Palindrome Partitioning II | Python | O(n^2) | O(n^2) | Hard || 139| Word Break | Python | O(n^2) | O(n) | Medium || 140| Word Break II | Python | O(n^2) | O(n) | Hard || 152| Maximum Product Subarray|Python| O(n) | O(1) | Medium || 174| Dungeon Game | Python| O(m * n) | O(m + n) | Hard || 188| Best Time to Buy and Sell Stock IV| Python | O(k * n) | O(k) | Hard || 198| House Robber| Python | O(n) | O(1) | Easy || 213| House Robber II| C++ Python | O(n) | O(1) | Medium || 221| Maximal Square| C++ Python | O(n^2) | O(n) | Medium | EPI | 256| Paint House | C++ Python | O(n)| O(1)| Medium |πŸ“–|| 265| Paint House II | C++ Python | O(n * k)| O(k)| Hard |πŸ“–|| 276| Paint Fence | C++ Python | O(n)| O(1)| Easy |πŸ“–||


##Backtracking

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 126| Word Ladder II |Python | O(n * d) | O(d) | Hard ||


##Greedy

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 11| Container With Most Water| Python | O(n) | O(1) | Medium || 42| Trapping Rain Water | Python | O(n) | O(1) | Hard || Tricky 44| Wildcard Matching | Python | O(m + n) | O(1) | Hard || Tricky 45| Jump Game II | Python | O(n) | O(1) | Hard || 55| Jump Game | Python | O(n) | O(1) | Medium || 84| Largest Rectangle in Histogram | Python | O(n) | O(n) | Hard || Tricky 122| Best Time to Buy and Sell Stock II| Python | O(n) | O(1) | Medium || 134| Gas Station| Python | O(n) | O(1) | Medium || 135| Candy| Python | O(n) | O(n) | Hard ||


##SQL

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 175| Combine Two Tables | MySQL | O(m + n) | O(m + n) | Easy || 176| Second Highest Salary | MySQL | O(n) | O(1) | Easy || 177| Nth Highest Salary | MySQL | O(n^2) | O(n) | Medium || 178| Rank Scores | MySQL | O(n^2) | O(n) | Medium || 180| Consecutive Numbers | MySQL | O(n) | O(n) | Medium || 181| Employees Earning More Than Their Managers | MySQL | O(n^2) | O(1) | Easy || 182| Duplicate Emails | MySQL | O(n^2) | O(n) | Easy || 183| Customers Who Never Order | MySQL | O(n^2) | O(1) | Easy || 184| Department Highest Salary | MySQL | O(n^2) | O(n) | Medium || 185| Department Top Three Salaries | MySQL | O(n^2) | O(n) | Hard || 196| Delete Duplicate Emails | MySQL | O(n^2) | O(n) | Easy || 197| Rising Temperature | MySQL | O(n^2) | O(n) | Easy || 262| Trips and Users | MySQL | O((t * u) + tlogt) | O(t) | Hard ||


##Shell Script

| Problem | Solution | Time | Space | Difficulty | Tag | Note

-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------| ----- 192 | Word Frequency | Shell | O(n) | O(k) | Medium || 193 | Valid Phone Numbers | Shell | O(n) | O(1) | Easy || 194 | Transpose File | Shell | O(n^2) | O(n^2) | Medium || 195 | Tenth Line | Shell | O(n) | O(1) | Easy ||

About

Python Solutions of All 260 LeetCode Algorithms / 13 Database / 4 Shell Questions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 61.8%
  • C++ 36.2%
  • Java 1.4%
  • Other 0.6%