# | Title | Solutions | Time | Space | Video | Difficulty | Tag |
---|---|---|---|---|---|---|---|
1 | Two Sum | Solution | O(n) | O(n) | Easy | HashMap | |
2 | Add Two Numbers | Solution | O(max(m,n)) | O(1) | Medium | LinkedList | |
3 | Longest Substring Without Repeating Characters | Solution | O(n) | O(k) | Medium | HashMap, Sliding Window | |
4 | Median of Two Sorted Arrays | Solution | ? | ? | Hard | Divide and Conquer | |
5 | Longest Palindromic Substring | Solution | O(n^2) | O(1) | Medium | ||
6 | ZigZag Conversion | Solution | O(n) | O(n) | Easy | ||
7 | Reverse Integer | Solution | O(1) | O(1) | Easy | ||
8 | String to Integer (atoi) | Solution | O(n) | O(1) | Medium | ||
9 | Palindrome Number | Solution | O(n) | O(1) | Easy | ||
10 | Regular Expression Matching | Solution | O(m*n) | O(m*n) | Hard | DP | |
11 | Container With Most Water | Solution | O(n) | O(1) | Medium | ||
12 | Integer to Roman | Solution | O(1) | O(1) | Medium | Math, String | |
13 | Roman to Integer | Solution | O(1) | O(1) | Easy | Math, String | |
14 | Longest Common Prefix | Solution | O(S) (S is the sum of all characters in all strings) | O(1) | Easy | ||
15 | 3Sum | Solution | O(n^2) | O(1) | Medium | Two Pointers, Binary Search | |
16 | 3Sum Closest | Solution | O(nlogn) | O(1) | Medium | Two Pointers | |
17 | Letter Combinations of a Phone Number | Solution | O(n*4^n) | O(n) | Medium | Backtracking | |
18 | 4 Sum | Solution | O(n^2) | O(1) | Medium | Two Pointers | |
19 | Remove Nth Node From End of List | Solution | O(n) | O(1) | Medium | Linked List | |
20 | Valid Parentheses | Solution | O(n) | O(n) | Easy | Stack | |
21 | Merge Two Sorted Lists | Solution | O(n) | O(h) | Easy | Recursion | |
22 | Generate Parentheses | Solution | TBD | O(n) | Medium | Backtracking | |
23 | Merge k Sorted Lists | Solution | O(n*logk) | O(k) | Hard | Heap | |
24 | Swap Nodes in Pairs | Solution | O(n) | O(h) | Medium | Recursion, LinkedList | |
25 | Reverse Nodes in k-Group | Solution | O(n) | O(1) | Hard | Recursion, LinkedList | |
26 | Remove Duplicates from Sorted Array | Solution | O(n) | O(1) | Easy | Array | |
27 | Remove Element | Solution | O(n) | O(1) | Easy | ||
28 | Implement strStr() | Solution | O(n) | O(1) | Easy | String | |
29 | Divide Two Integers | Solution | O(?) | O(?) | Medium | ||
30 | Substring with Concatenation of All Words | Solution | O(n^2) | O(n) | Hard | HashMap | |
31 | Next Permutation | Solution | O(n) | O(1) | Medium | Array | |
32 | Longest Valid Parentheses | Solution | O(n) | O(n) | Hard | Stack, DP | |
33 | Search in Rotated Sorted Array | Solution | O(logn) | O(1) | Medium | Binary Search | |
34 | Search for a Range | Solution | O(logn) | O(1) | Medium | Array, Binary Search | |
35 | Search Insert Position | Solution | O(n) | O(1) | Easy | Array | |
36 | Valid Sudoku | Solution | O(1) | O(1) | Medium | ||
37 | Sudoku Solver | Solution | O((9!)^9) | O(1) | Hard | ||
38 | Count and Say | Solution | O(n*2^n) | O(2^n) | Easy | Recursion, LinkedList | |
39 | Combination Sum | Solution | O(k*n^k) | O(k) | Medium | Backtracking | |
40 | Combination Sum II | Solution | O(k*n^k) | O(k) | Medium | Backtracking | |
41 | First Missing Positive | Solution | O(n) | O(1) | Hard | Array | |
42 | Trapping Rain Water | Solution | O(n) | O(1) | Hard | ||
43 | Multiply Strings | Solution | O(n) | O(1) | Medium | Array, String | |
44 | Wildcard Matching | Solution | O(m*n) | O(m*n) | Hard | Backtracking, DP, Greedy, String | |
45 | Jump Game II | Solution | O(n) | O(1) | Hard | Array, Greedy | |
46 | Permutations | Solution | O(n*n!) | O(n) | Medium | Backtracking | |
47 | Permutations II | Solution | O(n*n!) | O(n) | Medium | Backtracking | |
48 | Rotate Image | Solution | O(n^2) | O(1) | Medium | Array | |
49 | Group Anagrams | Solution | O(m*klogk) | O(m*k) | Medium | HashMap | |
50 | Pow(x, n) | Solution | O(logn) | O(logn) | Medium | ||
51 | N-Queens | Solution | O(n!) | O(n) | Hard | ||
52 | N-Queens II | Solution | O(n!) | O(n) | Hard | Backtracking | |
53 | Maximum Subarray | Solution | O(n) | O(1) | Easy | Array | |
54 | Spiral Matrix | Solution | O(m*n) | O(m*n) | Medium | Array | |
55 | Jump Game | Solution | O(n) | O(1) | Medium | Greedy | |
56 | Merge Intervals | Solution | O(n*logn) | O(1) | Medium | Array, Sort | |
57 | Insert Intervals | Solution | O(n) | O(1) | Hard | Array, Sort | |
58 | Length of Last Word | Solution | O(n) | O(1) | Easy | ||
59 | Spiral Matrix II | Solution | O(n) | O(n) | Medium | ||
60 | Permutation Sequence | Solution | O(n^2) | O(n) | Medium | Math, Backtracking | |
61 | Rotate List | Solution | O(n) | O(1) | Medium | Linked List | |
62 | Unique Paths | Solution | O(m*n) | O(m*n) | Medium | DP | |
63 | Unique Paths II | Solution | O(m*n) | O(m*n) | Medium | DP | |
64 | Minimum Path Sum | Solution | O(m*n) | O(m*n) | Medium | DP | |
65 | Valid Number | Solution | O(n) | O(1) | Hard | ||
66 | Plus One | Solution | O(n) | O(1) | Easy | ||
67 | Add Binary | Solution | O(n) | O(1) | Easy | ||
68 | Text Justification | Solution | O(n) | O(1) | Hard | ||
69 | Sqrt(x) | Solution | O(logn) | O(1) | Easy | ||
70 | Climbing Stairs | Solution | O(n) | O(n) | Easy | DP | |
71 | Simplify Path | Solution | O(n) | O(n) | Medium | Stack | |
72 | Edit Distance | Solution | O(m*n) | O(m+n) | Hard | ||
73 | Set Matrix Zeroes | Solution | O(mn) | O(1) | Medium | ||
74 | Search a 2D Matrix | Solution | O(log(m*n)) | O(1) | Medium | Binary Search | |
75 | Sort Colors | Solution | O(n) | O(1) | Medium | Two Pointers | |
76 | Minimum Window Substring | Solution | O(n) | O(k) | Hard | Two Pointers | |
77 | Combinations | Solution | O(n!) | O(n) | Medium | Backtracking | |
78 | Subsets | Solution | O(n^2) | O(1) | Medium | Backtracking | |
79 | Word Search | Solution | O((m*n)^2) | O(m*n) | Medium | Backtracking, DFS | |
80 | Remove Duplicates from Sorted Array II | Solution | O(n) | O(n) | Medium | ||
81 | Search in Rotated Sorted Array II | Solution | O(logn) | O(1) | Medium | Binary Search | |
82 | Remove Duplicates from Sorted List II | Solution | O(n) | O(1) | Medium | Linked List | |
83 | Remove Duplicates from Sorted List | Solution | O(n) | O(1) | Easy | Linked List | |
84 | Largest Rectangle in Histogram | Solution | O(n) | O(n) | Hard | Array, Stack | |
85 | Maximal Rectangle | Solution | O(m*n) | O(n) | Hard | DP | |
86 | Partition List | Solution | O(n) | O(1) | Medium | Linked List | |
87 | Scramble String | Solution | O(n^4) | O(n^3 | Hard | Recursion | |
88 | Merge Sorted Array | Solution | O(max(m,n)) | O(1) | Easy | ||
89 | Gray Code | Solution | O(n) | O(1) | Medium | Bit Manipulation | |
90 | Subsets II | Solution | O(n^2) | O(1) | Medium | Backtracking | |
91 | Decode Ways | Solution | O(n) | O(n) | Medium | DP | |
92 | Reverse Linked List II | Solution | O(n) | O(1) | Medium | ||
93 | Restore IP Addresses | Solution | O(?) | O(?) | Medium | Backtracking | |
94 | Binary Tree Inorder Traversal | Solution | O(n) | O(h) | Medium | Binary Tree | |
95 | Unique Binary Search Trees II | Solution | O(?) | O(?) | Medium | Recursion | |
96 | Unique Binary Search Trees | Solution | O(n^2) | O(n) | Medium | Recursion, DP | |
97 | Interleaving String | Solution | O(?) | O(?) | Hard | DP | |
98 | Validate Binary Search Tree | Solution | O(n) | O(h) | Medium | DFS/Recursion | |
99 | Recover Binary Search Tree | Solution | O(?) | O(?) | Hard | ||
100 | Same Tree | Solution | O(n) | O(h) | Easy | DFS | |
101 | Symmetric Tree | Solution | O(n) | O(h) | Easy | DFS | |
102 | Binary Tree Level Order Traversal | Solution | O(n) | O(h) | Medium | BFS | |
103 | Binary Tree Zigzag Level Order Traversal | Solution | O(n) | O(h) | Medium | BFS,DFS | |
104 | Maximum Depth of Binary Tree | Solution | O(n) | O(h) | Easy | DFS | |
105 | Construct Binary Tree from Preorder and Inorder Traversal | Solution | O(n) | O(n) | Medium | Recursion, Tree | |
106 | Construct Binary Tree from Inorder and Postorder Traversal | Solution | O(n) | O(n) | Medium | Recursion, Tree | |
107 | Binary Tree Level Order Traversal II | Solution | O(nlogn) | O(h) | Easy | BFS | |
108 | Convert Sorted Array to Binary Search Tree | Solution | O(n) | O(h) | Easy | Tree | |
109 | Convert Sorted List to Binary Search Tree | Solution | O(n) | O(h) | Medium | DFS, Recursion | |
110 | Balanced Binary Tree | Solution | O(n) | O(1)~O(h) | Easy | DFS | |
111 | Minimum Depth of Binary Tree | Solution | O(n) | O(1)~O(h) | Easy | BFS, DFS | |
112 | Path Sum | Solution | O(n) | O(1) | Easy | DFS | |
113 | Path Sum II | Solution | O(n) | O(h) | Medium | DFS, Backtracking | |
114 | Flatten Binary Tree to Linked List | Solution | O(n) | O(h) | Medium | Tree | |
115 | Distinct Subsequences | Solution | O(m*n) | O(m*n) | Hard | DP | |
116 | Populating Next Right Pointers in Each Node | Solution | O(n) | O(1) | Medium | BFS | |
117 | Populating Next Right Pointers in Each Node II | Solution | O(n) | O(1) | Medium | BFS | |
118 | Pascal's Triangle | Solution | O(n^2) | O(1) | Easy | ||
119 | Pascal's Triangle II | Solution | O(n^2) | O(k) | Easy | ||
120 | Triangle | Solution | O(m*n) | O(n) | Medium | DP | |
121 | Best Time to Buy and Sell Stock | Solution | O(n) | O(1) | Easy | ||
122 | Best Time to Buy and Sell Stock II | Solution | O(n) | O(1) | Easy | Greedy | |
123 | Best Time to Buy and Sell Stock III | Solution | O(n) | O(1) | Hard | DP | |
124 | Binary Tree Maximum Path Sum | Solution | O(n) | O(h) | Hard | Tree, DFS | |
125 | Valid Palindrome | Solution | O(n) | O(1) | Easy | Two Pointers | |
126 | Word Ladder II | Solution | O(?) | O(?) | Hard | BFS | |
127 | Word Ladder | Solution | O(n^2) | O(n) | Medium | BFS | |
128 | Longest Consecutive Sequence | Solution | O(n) | O(n) | Hard | Union Find | |
129 | Sum Root to Leaf Numbers | Solution | O(n) | O(h) | Medium | DFS | |
130 | Surrounded Regions | Solution | O(?) | O(?) | Medium | ||
131 | Palindrome Partitioning | Solution | O(n^2) | O(n^2) | Medium | ||
132 | Palindrome Partitioning II | Solution | O(n^2) | O(n^2) | Hard | ||
133 | Clone Graph | Solution | O(n) | O(n) | Medium | HashMap, BFS, Graph | |
134 | Gas Station | Solution | O(n) | O(1) | Medium | Greedy | |
135 | Candy | Solution | O(n) | O(1) | Hard | Greedy | |
136 | Single Number | Solution | O(n) | O(1) | Easy | Bit Manipulation | |
137 | Single Number II | Solution | O(n) | O(1) | Medium | Bit Manipulation | |
138 | Copy List with Random Pointer | Solution | O(n) | O(n) | Medium | LinkedList, HashMap | |
139 | Word Break | Solution | O(n^2) | O(n) | Medium | DP, Pruning | |
140 | Word Break II | Solution | ? | O(n^2) | Hard | Backtracking/DFS | |
141 | Linked List Cycle | Solution | O(n) | O(1) | Easy | Linked List | |
142 | Linked List Cycle II | Solution | O(n) | O(1) | Medium | Linked List | |
143 | Reorder List | Solution | O(n) | O(1) | Medium | ||
144 | Binary Tree Preorder Traversal | Solution | O(n) | O(h) | Medium | Binary Tree | |
145 | Binary Tree Postorder Traversal | Solution | O(n) | O(h) | Hard | Binary Tree | |
146 | LRU Cache | Solution | amortized O(1) | O(k) | Hard | Doubly Linked List, LinkedHashMap | |
147 | Insertion Sort List | Solution | O(n^2) | O(1) | Medium | Linked List | |
148 | Sort List | Solution | O(nlogn) | O(h) | Medium | Linked List, Sort | |
149 | Max Points on a Line | Solution | O(?) | O(?) | Hard | ||
150 | Evaluate Reverse Polish Notation | Solution | O(?) | O(?) | Medium | ||
151 | Reverse Words in a String | Solution | O(n) | O(n) | Medium | String | |
152 | Maximum Product Subarray | Solution | O(n) | O(1) | Medium | Array | |
153 | Find Minimum in Rotated Sorted Array | Solution | O(logn) | O(1) | Medium | Array, Binary Search | |
154 | Find Minimum in Rotated Sorted Array II | Solution | O(logn) | O(1) | Hard | Array, Binary Search | |
155 | Min Stack | Solution | O(1) | O(n) | Easy | Stack | |
156 | Binary Tree Upside Down | Solution | O(n) | O(h) | Medium | Tree, Recursion | |
157 | Read N Characters Given Read4 | Solution | O(n) | O(1) | Easy | ||
158 | Read N Characters Given Read4 II - Call multiple times | Solution | O(n) | O(1) | Hard | ||
159 | Longest Substring with At Most Two Distinct Characters | Solution | O(n) | O(1) | Hard | String, Sliding Window | |
160 | Intersection of Two Linked Lists | Solution | O(m+n) | O(1) | Easy | Linked List | |
161 | One Edit Distance | Solution | O(n) | O(1) | |||
162 | Find Peak Element | Solution | O(1) | O(logn)/O(n) | Binary Search | ||
163 | Missing Ranges | Solution | O(n) | O(1) | |||
164 | Maximum Gap | Solution | O(n) | O(n) | Hard | ||
165 | Compare Version Numbers | Solution | O(n) | O(1) | Easy | ||
166 | Fraction to Recurring Decimal | Solution | O(1) | O(1) | Medium | HashMap | |
167 | Two Sum II - Input array is sorted | Solution | O(n) | O(1) | Easy | Binary Search | |
168 | Excel Sheet Column Title | Solution | O(n) | O(1) | Easy | ||
169 | Majority Element | Solution | O(n) | O(1) | Easy | ||
170 | Two Sum III - Data structure design | Solution | O(n) | O(n) | Easy | ||
171 | Excel Sheet Column Number | Solution | O(n) | O(1) | Easy | ||
172 | Factorial Trailing Zeroes | Solution | O(logn) | O(1) | Easy | ||
173 | Binary Search Tree Iterator | Solution | O(1) | O(h) | Medium | Stack, Design | |
174 | Dungeon Game | QueueStack | O(m*n) | O(m*n) | Hard | DP | |
179 | Largest Number | Solution | O(?) | O(?) | Medium | ||
186 | Reverse Words in a String II | Solution | O(n) | O(1) | Medium | ||
187 | Repeated DNA Sequences | Solution | O(n) | O(n) | Medium | ||
188 | Best Time to Buy and Sell Stock IV | Solution | O(n*k) | O(n*k) | Hard | DP | |
189 | Rotate Array | Solution | O(n) | O(n), could be optimized to O(1) | Easy | ||
190 | Reverse Bits | Solution | O(n) | O(1) | Easy | Bit Manipulation | |
191 | Number of 1 Bits | Solution | O(1) | O(1) | Easy | Bit Manipulation | |
198 | House Robber | Solution | O(n) | O(n) | Easy | DP | |
199 | Binary Tree Right Side View | Solution | O(n) | O(h) | Medium | BFS | |
200 | Number of Islands | Solution | O(m*n) | O(m*n) | Medium | Union Find, DFS | |
201 | Bitwise AND of Numbers Range | Solution | O(min(m,n)) | O(1) | Medium | Bit Manipulation | |
202 | Happy Number | Solution | O(k) | O(k) | Easy | ||
203 | Remove Linked List Elements | Solution | O(n) | O(1) | Easy | ||
204 | Count Primes | Solution | O(nloglogn) | O(n) | Easy | The Sieve of Eratosthenes | |
205 | Isomorphic Strings | Solution | O(n) | O(1) | Easy | ||
206 | Reverse Linked List | Solution | O(n) | O(1) | Easy | Linked List | |
207 | Course Schedule | Solution | O(?) | O(?) | Medium | ||
208 | Implement Trie | Solution | O(n) | O(1) | Medium | Trie | |
209 | Minimum Size Subarray Sum | Solution | O(n) | O(1) | Medium | ||
210 | Course Schedule II | Solution | O(?) | O(?) | Medium | ||
211 | Add and Search Word - Data structure design | Solution | O(n) | O(h) | Medium | Trie | |
212 | Word Search II | Solution | O(mnl) | O(l) | Hard | Trie | |
213 | House Robber II | Solution | O(n) | O(n) | Medium | DP | |
214 | Shortest Palindrome | Solution | O(?) | O(?) | Hard | KMP | |
215 | Kth Largest Element in an Array | Solution | O(nlogn) | O(n) | Medium | Heap | |
216 | Combination Sum III | Solution | O(k * C(n, k)) | O(k) | Medium | Backtracking | |
217 | Contains Duplicate | Solution | O(n) | O(n) | Easy | HashSet | |
218 | The Skyline Problem | Solution | O(n) | O(n) | Hard | TreeMap, Design | |
219 | Contains Duplicate II | Solution | O(n) | O(n) | Easy | HashMap | |
220 | Contains Duplicate III | Solution | O(nlogn) | O(n) | Medium | TreeSet | |
221 | Maximal Square | Solution | O(?) | O(h) | Medium | Recursion | |
222 | Count Complete Tree Nodes | Solution | O(?) | O(h) | Medium | Recursion | |
223 | Rectangle Area | Solution | O(1) | O(1) | Easy | ||
224 | Basic Calculator | Solution | ? | ? | Hard | ||
225 | Implement Stack using Queues | Solution | O(n) | O(n) | Easy | Stack, Queue | |
226 | Invert Binary Tree | Solution | O(n) | O(h) | Easy | DFS, recursion | |
227 | Basic Calculator II | Solution | O(n) | O(n) | Medium | String | |
228 | Summary Ranges | Solution | O(n) | O(1) | Medium | Array | |
229 | Majority Element II | Solution | O(n) | O(1) | Medium | ||
230 | Kth Smallest Element in a BST | Solution | O(n) | O(k) | Medium | Tree | |
231 | Power of Two | Solution | O(1) | O(1) | Easy | ||
232 | Implement Queue using Stacks | Solution | O(n) | O(n) | Medium | Stack, Design | |
233 | Number of Digit One | Solution | O(n) | O(1) | Hard | Math | |
234 | Palindrome Linked List | Solution | O(n) | O(1) | Easy | Linked List | |
235 | Lowest Common Ancestor of a Binary Search Tree | Solution | O(h) | O(1) | Easy | DFS | |
236 | Lowest Common Ancestor of a Binary Tree | Solution | O(n) | O(h) | Medium | DFS | |
237 | Delete Node in a Linked List | Solution | O(1) | O(1) | Easy | LinkedList | |
238 | Product of Array Except Self | Solution | O(n) | O(1) | Medium | Array | |
239 | Sliding Window Maximum | Solution | O(nlogn) | O(k) | Hard | Heap | |
240 | Search a 2D Matrix II | Solution | O(m+n) | O(1) | Medium | Binary Search | |
241 | Different Ways to Add Parentheses | Solution | O(O(n * 4^n / n^(3/2))) | O(n * 4^n / n^(3/2)) | Medium | Divide and Conquer | |
242 | Valid Anagram | Solution | O(n) | O(1) | Easy | ||
243 | Shortest Word Distance | Solution | O(n) | O(1) | Easy | ||
244 | Shortest Word Distance II | Solution | O(n) | O(n) | Medium | HashMap | |
245 | Shortest Word Distance III | Solution | O(n) | O(1) | Medium | ||
246 | Strobogrammatic Number | Solution | O(n) | O(1) | Easy | ||
247 | Strobogrammatic Number II | Solution | O(n^2) | O(n) | Medium | Recursion | |
248 | Strobogrammatic Number III | Solution | O(?) | O(?) | Hard | Recursion, DFS | |
249 | Group Shifted Strings | Solution | O(nlogn) | O(n) | |||
250 | Count Univalue Subtrees | Solution | O(n) | O(h) | Medium | DFS | |
251 | Flatten 2D Vector | Solution | O(1) | O(m*n) | Medium | ||
252 | Meeting Rooms | Solution | O(nlogn) | O(1) | Easy | ||
253 | Meeting Rooms II | Solution | O(nlogn) | O(h) | Medium | Heap | |
254 | Factor Combinations | Solution | O(nlogn) | O(nlogn) | Medium | Backtracking | |
255 | Verify Preorder Sequence in Binary Search Tree | Solution | O(n) | O(h) | Medium | Tree | |
256 | Paint House | Solution | O(n) | O(1) | Medium | DP | |
257 | Binary Tree Paths | Solution | O(n*h) | O(h) | DFS/Recursion | ||
258 | Add Digits | Solution | O(1) | O(1) | Easy | ||
259 | 3Sum Smaller | Solution | O(n^2) | O(1) | Medium | ||
260 | Single Number III | Solution | O(n) | O(n) | Medium | ||
261 | Graph Valid Tree | Solution | O(V+E) | O(V+E) | Medium | ||
263 | Ugly Number | Solution | O(n) | O(1) | Easy | ||
264 | Ugly Number II | Solution | O(n) | O(n) | Medium | DP | |
265 | Paint House II | Solution | O(n*k) | O(1) | Hard | DP | |
266 | Palindrome Permutation | Solution | O(n) | O(1) | Easy | ||
267 | Palindrome Permutation II | Solution | O(n*n!) | O(n) | Medium | ||
268 | Missing Number | Solution | O(n) | O(1) | Easy | Bit Manipulation | |
269 | Alien Dictionary | Solution | O(?) | O(?) | Hard | Topological Sort | |
270 | Closest Binary Search Tree Value | Solution | O(h) | O(1) | Easy | DFS | |
271 | Encode and Decode Strings | Solution | O(n) | O(1) | Medium | ||
272 | Closest Binary Search Tree Value II | Solution | O(h+k) | O(h) | Hard | Stack | |
273 | Integer to English Words | Solution | O(n) | O(1) | Hard | Math, String | |
274 | H-Index | Solution | O(nlogn) | O(1) | Medium | ||
275 | H-Index II | Solution | O(logn) | O(1) | Medium | Binary Search | |
276 | Paint Fence | Solution | O(n) | O(1) | Easy | DP | |
277 | Find the Celebrity | Solution | O(n) | O(1) | Medium | ||
278 | First Bad Version | Solution | O(logn) | O(1) | Easy | Binary Search | |
279 | Perfect Squares | Solution | O(n) | O(1) | Medium | ||
280 | Wiggle Sort | Solution | O(n) | O(1) | Medium | ||
281 | Zigzag Iterator | Solution | O(1) | O(k) | Medium | ||
282 | Expression Add Operators | Solution | O(?) | O(?) | Hard | ||
283 | Move Zeroes | Solution | O(n) | O(1) | Easy | ||
284 | Peeking Iterator | Solution | O(n) | O(n) | Medium | Design | |
285 | Inorder Successor In BST | Solution | O(h) | O(1) | Medium | Tree | |
286 | Walls and Gates | Solution | O(m*n) | O(g) | Medium | BFS | |
287 | Find the Duplicate Number | Solution | O(n) | O(1) | Medium | ||
288 | Unique Word Abbreviation | Solution | O(n) | O(1) | Easy | ||
289 | Game of Life | Solution | O(m*n) | O(m*n), could be optimized to O(1) | Medium | ||
290 | Word Pattern | Solution | O(n) | O(n) | Easy | HashMap | |
291 | Word Pattern II | Solution | O(n) | O(n) | Hard | Recursion, Backtracking | |
292 | Nim Game | Solution | O(1) | O(1) | Easy | ||
293 | Flip Game | Solution | O(n) | O(1) | Easy | ||
294 | Flip Game II | Solution | O(?) | O(?) | Medium | Backtracking | |
295 | Find Median from Data Stream | Solution | O(logn) | O(n) | Hard | Heap | |
296 | Best Meeting Point | Solution | ? | ? | Hard | ||
297 | Serialize and Deserialize Binary Tree | Solution | O(n) | O(h) | Hard | BFS | |
298 | Binary Tree Longest Consecutive Sequence | Solution | O(n) | O(n) | Medium | Tree | |
299 | Bulls and Cows | Solution | O(n) | O(1) | Easy | ||
300 | Longest Increasing Subsequence | Solution | O(logn) | O(n) | Medium | DP | |
301 | Remove Invalid Parentheses | Solution | ? | ? | Hard | BFS | |
302 | Smallest Rectangle Enclosing Black Pixels | Solution | ? | O(m*n) | Hard | DFS, BFS | |
303 | Range Sum Query - Immutable | Solution | O(n) | O(1) | Easy | ||
304 | Range Sum Query 2D - Immutable | Solution | ? | ? | Medium | ||
305 | Number of Islands II | Solution | ? | ? | Hard | Union Find | |
306 | Additive Number | Solution | O(n^2) | O(n) | Medium | ||
307 | Range Sum Query - Mutable | Solution | ? | ? | Medium | Tree | |
308 | Range Sum Query 2D - Mutable | Solution | ? | ? | Hard | Tree | |
309 | Best Time to Buy and Sell Stock with Cooldown | Solution | O(n) | O(1) | Medium | DP | |
310 | Minimum Height Trees | Solution | ? | ? | Medium | ||
311 | Sparse Matrix Multiplication | Solution | O(mnl) | O(m*l) | Medium | ||
312 | Burst Balloons | Solution | O(?) | O(?) | Hard | DP | |
313 | Super Ugly Number | Solution | O(?) | O(?) | Medium | ||
314 | Binary Tree Vertical Order Traversal | Solution | O(n) | O(n) | Medium | HashMap, BFS | |
315 | Count of Smaller Numbers After Self | Solution | O(?) | O(?) | Hard | Tree | |
316 | Remove Duplicate Letters | Solution | O(n) | O(1) | Hard | Stack, Recursion, Greedy | |
317 | Shortest Distance from All Buildings | Solution | O(?) | O(?) | Hard | ||
318 | Maximum Product of Word Lengths | Solution | O(n^2) | O(n) | Medium | ||
319 | Bulb Switcher | Solution | O(1) | O(1) | Medium | Brainteaser | |
320 | Generalized Abbreviation | Solution | O(n*2^n) | O(n) | Medium | Backtracking, Bit Manipulation | |
321 | Create Maximum Number | Solution | O(?) | O(?) | Hard | ||
322 | Coin Change | Solution | O(n*k) | O(k) | Medium | DP | |
323 | Number of Connected Components in an Undirected Graph | Solution | O(?) | O(?) | Medium | ||
324 | Wiggle Sort II | Solution | O(n) | O(n) | Medium | Sort | |
325 | Maximum Size Subarray Sum Equals k | Solution | O(n) | O(n) | Medium | HashTable | |
326 | Power of Three | Solution | O(1) | O(1) | Easy | Math | |
327 | Count of Range Sum | Solution | O(nlogn) | O(n) | Hard | BST, Divide and Conquer | |
328 | Odd Even Linked List | Solution | O(n) | O(1) | Medium | Linked List | |
329 | Longest Increasing Path in a Matrix | Solution | O(m*n) | O(m*n) | Hard | DFS, DP | |
330 | Patching Array | Solution | O(m+logn) | O(1) | Hard | Greedy | |
331 | Verify Preorder Serialization of a Binary Tree | Solution | O(n) | O(n) | Medium | Stack | |
332 | Reconstruct Itinerary | Solution | O(n) | O(n) | Medium | Graph, DFS | |
333 | Largest BST Subtree | Solution | O(n) | O(n) | Medium | Tree | |
334 | Increasing Triplet Subsequence | Solution | O(n) | O(1) | Medium | ||
335 | Self Crossing | Solution | O(n) | O(1) | Hard | Math | |
336 | Palindrome Pairs | Solution | O(n^2) | O(n) | Hard | ||
337 | House Robber III | Solution | O(n) | O(n) | Medium | DP | |
338 | Counting Bits | Solution | O(nlogn) | O(h) | Medium | ||
339 | Nested List Weight Sum | Solution | O(n) | O(h)) | Easy | DFS | |
340 | Longest Substring with At Most K Distinct Characters | Solution | O(n) | O(1) | Hard | Sliding Window | |
341 | Flatten Nested List Iterator | Solution | O(n) | O(n) | Medium | Stack | |
342 | Power of Four | Solution | O(n) | O(1) | Easy | Math | |
343 | Integer Break | Solution | O(1) | O(1) | Medium | Math | |
344 | Reverse String | Solution | O(n) | O(1) | Easy | String | |
345 | Reverse Vowels of a String | Solution | O(n) | O(1) | Easy | String | |
346 | Moving Average from Data Stream | Solution | O(1) | O(w)) | Easy | Queue | |
347 | Top K Frequent Elements | Solution | O(n) | O(k) k is is the number of unique elements in the given array | Medium | HashTable, Heap, Bucket Sort | |
348 | Design Tic-Tac-Toe | Solution | O(1) | O(n) | Medium | Design | |
349 | Intersection of Two Arrays | Solution | O(m+n) | O(min(m,n)) | Easy | Two Pointers, Binary Search | |
350 | Intersection of Two Arrays II | Solution | O(m+n) | O((m+n)) could be optimized | Easy | HashMap, Binary Search | |
351 | Android Unlock Patterns | Solution | O(?) | O(?) | Medium | ||
352 | Data Stream as Disjoint Intervals | Solution | O(logn) | O(n) | Hard | TreeMap | |
353 | Design Snake Game | Solution | O(?) | O(?) | Medium | ||
354 | Russian Doll Envelopes | Solution | O(nlogn) | O(1) | Hard | DP, Binary Search | |
355 | Design Twitter | Solution | O(n) | O(n) | Medium | Design, HashMap, Heap | |
356 | Line Reflection | Solution | O(n) | O(n) | Medium | HashSet | |
357 | Count Numbers with Unique Digits | Solution | O(n) | O(1) | Medium | DP, Math | |
358 | Rearrange String k Distance Apart | Solution | O(n) | O(n) | Hard | HashMap, Heap, Greedy | |
359 | Logger Rate Limiter | Solution | amortized O(1) | O(k) | Easy | HashMap | |
360 | Sort Transformed Array | Solution | O(n) | O(1) | Medium | Two Pointers, Math | |
361 | Bomb Enemy | Solution | O(?) | O(?) | Medium | ||
362 | Design Hit Counter | Solution | O(1) amortized | O(k) | Medium | Design | |
363 | Max Sum of Rectangle No Larger Than K | Solution | Hard | DP | |||
364 | Nested List Weight Sum II | Solution | O(n) | O(h) | Medium | DFS | |
365 | Water and Jug Problem | Solution | O(n) | O(1) | Medium | Math | |
366 | Find Leaves of Binary Tree | Solution | O(n) | O(h) | Medium | DFS | |
367 | Valid Perfect Square | Solution | O(n) | O(1) | Medium | ||
368 | Largest Divisible Subset | Solution | O(n^2) | O(n) | Medium | DP | |
369 | Plus One Linked List | Solution | O(n) | O(1) | Medium | Linked List | |
370 | Range Addition | Solution | O(n+k) | O(1) | Medium | Array | |
371 | Sum of Two Integers | Solution | O(n) | O(1) | Easy | ||
372 | Super Pow | Solution | O(n) | O(1) | Medium | Math | |
373 | Find K Pairs with Smallest Sums | Solution | O(klogk) | O(k) | Medium | Heap | |
374 | Guess Number Higher or Lower | Solution | O(logn) | O(1) | Easy | Binary Search | |
375 | Guess Number Higher or Lower II | Solution | O(n^2) | O(n^2) | Medium | DP | |
376 | Wiggle Subsequence | Solution | O(n) | O(1) | Medium | DP, Greedy | |
377 | Combination Sum IV | Solution | O(n^2) | O(n) | Medium | DP | |
378 | Kth Smallest Element in a Sorted Matrix | Solution | O(logm*n) | O(1) | Medium | Binary Search | |
379 | Design Phone Directory | Solution | O(1) | O(n) | Medium | ||
380 | Insert Delete GetRandom O(1) | Solution | O(n) | O(1) | Medium | Design, HashMap | |
381 | Insert Delete GetRandom O(1) - Duplicates allowed | Solution | Hard | ||||
382 | Linked List Random Node | Solution | O(1) | O(n) | Medium | Reservoir Sampling | |
383 | Ransom Note | Solution | O(n) | O(n) | Easy | String | |
384 | Shuffle an Array | Solution | O(n) | O(n) | Medium | ||
385 | Mini Parser | Solution | O(n) | O(h) | Medium | Stack | |
386 | Lexicographical Numbers | Solution | O(n) | O(1) | Medium | ||
387 | First Unique Character in a String | Solution | O(n) | O(n) | Easy | HashMap | |
388 | Longest Absolute File Path | Solution | O(n) | O(d) | Medium | Stack | |
389 | Find the Difference | Solution | O(n) | O(1) | Easy | ||
390 | Elimination Game | Solution | O(logn) | O(1) | Medium | ||
391 | Perfect Rectangle | Solution | O(n) | O(1) | Hard | ||
392 | Is Subsequence | Solution | O(m*n) | O(1) | Medium | Array, String | |
393 | UTF-8 Validation | Solution | O(?) | O(?) | Medium | Bit Manipulation | |
395 | Longest Substring with At Least K Repeating Characters | Solution | O(n^2) | O(1) | Medium | Recursion | |
396 | Rotate Function | Solution | O(n^2) could be optimized to O(n) | O(1) | Easy | ||
397 | Integer Replacement | Solution | ? | ? | Easy | BFS | |
398 | Random Pick Index | Solution | Medium | Reservoir Sampling | |||
399 | Evaluate Division | Solution | O(n*n!) | O(n) | Medium | Graph, DFS, Backtracking | |
400 | Nth Digit | Solution | O(n) | O(1) | Easy | ||
401 | Binary Watch | Solution | O(1) | O(1) | Easy | ||
402 | Remove K Digits | Solution | O(n) | O(n) | Medium | Greedy, Stack | |
403 | Frog Jump | Solution | O(n^2) | O(n^2) | Hard | DP | |
404 | Sum of Left Leaves | Solution | O(n) | O(h) | Easy | ||
405 | Convert a Number to Hexadecimal | Solution | O(n) | O(1) | Easy | ||
406 | Queue Reconstruction by Height | Solution | O(nlogn) | O(1) | Medium | LinkedList, PriorityQueue | |
407 | Trapping Rain Water II | Solution | Hard | Heap | |||
408 | Valid Word Abbreviation | Solution | O(n) | O(1) | Easy | ||
410 | Split Array Largest Sum | Solution | O(nlogn) | O(1) | Hard | Binary Search, DP | |
411 | Minimum Unique Word Abbreviation | Solution | O(?) | O(?) | Hard | NP-Hard, Backtracking, Trie, Recursion | |
412 | Fizz Buzz | Solution | O(n) | O(1) | Easy | ||
413 | Arithmetic Slices | Solution | O(n) | O(1) | Medium | DP | |
414 | Third Maximum Number | Solution | O(n) | O(1) | Easy | ||
415 | Add Strings | Solution | O(n) | O(1) | Easy | ||
416 | Partition Equal Subset Sum | Solution | O(m*n) | O(m*n) | Medium | DP | |
417 | Pacific Atlantic Water Flow | Solution | O(mnMax(m,n)) | O(m*n) | Medium | DFS | |
418 | Sentence Screen Fitting | Solution | O(n) | O(1) | Medium | ||
419 | Battleships in a Board | Solution | O(m*n) | O(1) | Medium | DFS | |
420 | Strong Password Checker | Solution | ? | ? | Hard | ||
421 | Maximum XOR of Two Numbers in an Array | Solution | O(n) | O(1) | Medium | Bit Manipulation, Trie | |
422 | Valid Word Square | Solution | O(n) | O(1) | Easy | ||
423 | Reconstruct Original Digits from English | Solution | O(n) | O(1) | Medium | Math | |
424 | Longest Repeating Character Replacement | Solution | O(n) | O(1) | Medium | Sliding Window | |
425 | Word Squares | Solution | O(n!) | O(n) | Hard | Trie, Backtracking, Recursion | |
432 | All O`one Data Structure | Solution | O(1) | O(n) | Hard | Design | |
434 | Number of Segments in a String | Solution | O(n) | O(1) | Easy | ||
435 | Non-overlapping Intervals | Solution | O(nlogn) | O(1) | Medium | Greedy | |
436 | Find Right Interval | Solution | O(nlogn) | O(n) | Medium | Binary Search | |
437 | Path Sum III | Solution | O(n^2) | O(n) | Easy | DFS, recursion | |
438 | Find All Anagrams in a String | Solution | O(n) | O(1) | Easy | Sliding Window | |
439 | Ternary Expression Parser | Solution | O(n) | O(n) | Medium | Stack | |
440 | K-th Smallest in Lexicographical Order | Solution | O(n^2) | O(1) | Hard | ||
441 | Arranging Coins | Solution | O(n) | O(1) | Easy | ||
442 | Find All Duplicates in an Array | Solution | O(n) | O(1) | Medium | Array | |
443 | String Compression | Solution | O(n) | O(n) | Easy | ||
444 | Sequence Reconstruction | Solution | O(n) | O(n) | Medium | Topological Sort, Graph | |
445 | Add Two Numbers II | Solution | O(max(m,n) | O(max(m,n)) | Medium | Stack, LinkedList | |
446 | Arithmetic Slices II - Subsequence | Solution | O(n^2) | O(n^2) | Hard | DP | |
447 | Number of Boomerangs | Solution | O(n^2) | O(n) | Easy | HashMap | |
448 | Find All Numbers Disappeared in an Array | Solution | O(n) | O(1) | Easy | Array, HashMap | |
449 | Serialize and Deserialize BST | Solution | O(n) | O(h) | Medium | BFS | |
450 | Delete Node in a BST | Solution | O(?) | O(?) | Medium | Tree, Recursion | |
451 | Sort Characters By Frequency | Solution | O(nlogn) | O(n) | Medium | HashMap | |
452 | Minimum Number of Arrows to Burst Balloons | Solution | O(nlogn) | O(1) | Medium | Array, Greedy | |
453 | Minimum Moves to Equal Array Elements | Solution | O(n) | O(1) | Easy | ||
454 | 4Sum II | Solution | O(n) | O(n) | Medium | HashMap | |
455 | Assign Cookies | Solution | O(n) | O(1) | Easy | ||
456 | 132 Pattern | Solution | O(n) | O(n) | Medium | Stack | |
457 | Circular Array Loop | Solution | O(n) | O(1) | Medium | ||
458 | Poor Pigs | Solution | O(1) | O(1) | Easy | Math | |
459 | Repeated Substring Pattern | Solution | O(n) | O(n) | Easy | String, KMP | |
460 | LFU Cache | Solution | O(1) | O(n) | Hard | Design, LinkedHashMap, HashMap | |
461 | Hamming Distance | Solution | O(n) | O(1) | Easy | ||
462 | Minimum Moves to Equal Array Elements II | Solution | O(nlogn) | O(1) | Medium | ||
463 | Island Perimeter | Solution | O(m*n) | O(1) | Easy | ||
464 | Can I Win | Solution | O(2^n) | O(n) | Medium | DP | |
465 | Optimal Account Balancing | Solution | Hard | DP | |||
466 | Count The Repetitions | Solution | O(max(m,n)) | O(1) | Hard | DP | |
467 | Unique Substrings in Wraparound String | Solution | O(n) | O(1) | Medium | DP | |
468 | Validate IP Address | Solution | O(n) | O(1) | Medium | String | |
469 | Convex Polygon | Solution | O(n) | O(1) | Medium | Math | |
471 | Encode String with Shortest Length | Solution | O(n^3) | O(n^2) | Hard | DP | |
472 | Concatenated Words | Solution | O(n^2) | O(n) | Hard | Trie, DP, DFS | |
473 | Matchsticks to Square | Solution | O(n!) | O(n) | Medium | Backtracking, DFS | |
474 | Ones and Zeroes | Solution | O(n) | O(m*n) | Medium | DP | |
475 | Heaters | Solution | max(O(nlogn), O(mlogn)) - m is the length of houses, n is the length of heaters | O(1) | Easy | Array Binary Search | |
476 | Number Complement | Solution | O(n) | O(1) | Easy | Bit Manipulation | |
477 | Total Hamming Distance | Solution | O(n) | O(1) | Medium | Bit Manipulation | |
479 | Largest Palindrome Product | Solution | O(n) | O(1) | Easy | ||
480 | Sliding Window Median | Solution | O(nlogk) | O(k) | Hard | Heap | |
481 | Magical String | Solution | O(?) | O(?) | Medium | ||
482 | License Key Formatting | Solution | O(n) | O(n) | Medium | ||
483 | Smallest Good Base | Solution | O(logn) | O(1) | Hard | Binary Search, Math | |
484 | Find Permutation | Solution | O(n) | O(1) | Medium | Array, String, Greedy | |
485 | Max Consecutive Ones | Solution | O(n) | O(1) | Easy | Array | |
486 | Predict the Winner | Solution | O(2^n) | O(n^2) | Medium | DP | |
487 | Max Consecutive Ones II | Solution | O(n) | O(n) | Medium | Array | |
488 | Zuma Game | Solution | O(?) | O(?) | Hard | DFS, Backtracking | |
490 | The Maze | Solution | O(m*n) | O(m*n) | Medium | BFS | |
491 | Increasing Subsequences | Solution | O(n!) | O(n) | Medium | Backtracking, DFS | |
492 | Construct the Rectangle | Solution | O(n) | O(1) | Easy | Array | |
493 | Reverse Pairs | Solution | O(nlogn) | O(1) | Hard | Recursion | |
494 | Target Sum | Solution | O(2^n) | O(1) | Medium | ||
495 | Teemo Attacking | Solution | O(n) | O(1) | Medium | Array | |
498 | Diagonal Traverse | Solution | O(m*n) | O(1) | Medium | ||
496 | Next Greater Element I | Solution | O(n*m) | O(1) | Easy | ||
499 | The Maze III | Solution | O(m*n) | O(m*n) | Hard | BFS | |
500 | Keyboard Row | Solution | O(n) | O(1) | Easy | ||
501 | Find Mode in Binary Tree | Solution | O(n) | O(k) | Easy | Binary Tree | |
502 | IPO | Solution | O(nlogn) | O(n) | Hard | Heap, Greedy | |
503 | Next Greater Element II | Solution | O(n) | O(n) | Medium | Stack | |
504 | Base 7 | Solution | O(1) | O(1) | Easy | ||
505 | The Maze II | Solution | O(m*n) | O(m*n) | Medium | BFS | |
506 | Relative Ranks | Solution | O(nlogn) | O(n) | Easy | ||
507 | Perfect Number | Solution | O(sqrt(n)) | O(1) | Easy | Math | |
508 | Most Frequent Subtree Sum | Solution | O(n) | O(n) | Medium | DFS, Tree | |
513 | Find Bottom Left Tree Value | Solution | O(n) | O(k) | Medium | BFS | |
514 | Freedom Trail | Solution | O(?) | O(?) | Hard | DP | |
515 | Find Largest Value in Each Tree Row | Solution | O(n) | O(k) | Medium | BFS | |
516 | Longest Palindromic Subsequence | Solution | O(n^2) | O(n^2) | Medium | DP | |
517 | Super Washing Machines | Solution | Hard | DP | |||
520 | Detect Capital | Solution | O(n) | O(1) | Easy | ||
521 | Longest Uncommon Subsequence I | Solution | O(max(x,y)) (x and y are length of strings) | O(1) | Easy | ||
522 | Longest Uncommon Subsequence II | Solution | O(x*n^2) (x is average length of strings) | O(1) | Medium | ||
523 | Continuous Subarray Sum | Solution | O(n) | O(1) | Medium | DP | |
524 | Longest Word in Dictionary through Deleting | Solution | O(n) | O(n) | Medium | Sort | |
525 | Contiguous Array | Solution | O(n) | O(n) | Medium | HashMap | |
526 | Beautiful Arrangement | Solution | O(n) | O(h) | Medium | Backtracking | |
527 | Word Abbreviation | Solution | O(n^2) | O(n) | Hard | ||
529 | Minesweeper | Solution | O(m*n) | O(k) | Medium | BFS | |
530 | Minimum Absolute Difference in BST | Solution | O(n) | O(n) | Easy | DFS | |
531 | Lonely Pixel I | Solution | O(m*n) | O(1) | Medium | ||
532 | K-diff Pairs in an Array | Solution | O(n) | O(n) | Easy | HashMap | |
533 | Lonely Pixel II | Solution | O(m*n) | O(m) (m is number of rows) | Medium | HashMap | |
535 | Encode and Decode TinyURL | Solution | O(1) | O(n) | Medium | Design | |
536 | Construct Binary Tree from String | Solution | O(n) | O(h) | Medium | Recursion, Stack | |
537 | Complex Number Multiplication | Solution | O(1) | O(1) | Medium | Math, String | |
538 | Convert BST to Greater Tree | Solution | O(n) | O(h) | Easy | Tree | |
539 | Minimum Time Difference | Solution | O(logn) | O(1) | Medium | String | |
540 | Single Element in a Sorted Array | Solution | O(n) | O(1) | Medium | ||
541 | Reverse String II | Solution | O(n) | O(1) | Easy | String | |
542 | 01 Matrix | Solution | O(m*n) | O(n) | Medium | BFS | |
543 | Diameter of Binary Tree | Solution | O(n) | O(h) | Easy | Tree/DFS/Recursion | |
544 | Output Contest Matches | Solution | O(n) | O(n) | Medium | Recursion | |
545 | Boundary of Binary Tree | Solution | O(n) | O(n) | Medium | Recursion | |
546 | Remove Boxes | Solution | O(n^3) | O(n^3) | Hard | DFS, DP | |
547 | Friend Circles | Solution | O(n^2) | O(n) | Medium | Union Find | |
548 | Split Array with Equal Sum | Solution | O(n^2) | O(n) | Medium | Array | |
549 | Binary Tree Longest Consecutive Sequence II | Solution | O(n) | O(n) | Medium | Tree | |
551 | Student Attendance Record I | Solution | O(n) | O(1) | Easy | String | |
552 | Student Attendance Record II | Solution | O(n) | O(1) | Hard | DP | |
553 | Optimal Division | Solution | O(n) | O(n) | Medium | String, Math | |
554 | Brick Wall | Solution | O(n) (n is total number of bricks in the wall) | O(m) (m is width of the wall) | Medium | HashMap | |
555 | Split Concatenated Strings | Solution | O(n^2) | O(n) | Medium | String | |
556 | Next Greater Element III | Solution | O(n) | O(1) | Medium | String | |
557 | Reverse Words in a String III | Solution | O(n) | O(n) | Easy | String | |
560 | Subarray Sum Equals K | Solution | O(n) | O(n) | Medium | Array, HashMap | |
561 | Array Partition I | Solution | O(nlogn) | O(1) | Easy | Array | |
562 | Longest Line of Consecutive One in Matrix | Solution | O(m*n) | O(m*n) | Medium | Matrix DP | |
563 | Binary Tree Tilt | Solution | O(n) | O(n) | Easy | Tree Recursion | |
565 | Array Nesting | Solution | O(n) | O(n) | Medium | ||
566 | Reshape the Matrix | Solution | O(m*n) | O(1) | Easy | ||
567 | Permutation in String | Solution | O(l1 + 26*(l2 - l1)) | O(1) | Medium | Sliding Windows, Two Pointers | |
568 | Maximum Vacation Days | Solution | O(n^2*k) | O(n*k) | Hard | DP | |
572 | Subtree of Another Tree | Solution | O(m*n) | O(1) | Easy | Tree | |
573 | Squirrel Simulation | Solution | O(n) | O(1) | Medium | Math | |
575 | Distribute Candies | Solution | O(nlogn) | O(1) | Easy | Array | |
576 | Out of Boundary Paths | Solution | O(Nmn) | O(m*n) | Hard | DP, DFS | |
581 | Shortest Unsorted Continuous Subarray | Solution | O(n) | O(1) | Easy | Array, Sort | |
582 | Kill Process | Solution | O(n) | O(h) | Medium | Stack | |
583 | Delete Operation for Two Strings | Solution | O(m*n) | O(m*n) could be optimized to O(n) | Medium | DP | |
587 | Erect the Fence | Solution | O(?) | O(?) | Hard | Geometry | |
588 | Design In-Memory File System | Solution | O(n) | O(h) | Hard | Trie, Design | |
591 | Tag Validator | Solution | O(n) | O(n) | Hard | Stack, String | |
592 | Fraction Addition and Subtraction | Solution | O(nlogx) | O(n) | Medium | Math | |
593 | Valid Square | Solution | O(1) | O(1) | Medium | Math | |
594 | Longest Harmonious Subsequence | Solution | O(n) | O(n) | Easy | Array, HashMap | |
598 | Range Addition II | Solution | O(x) (x is the number of operations) | O(1) | Easy | ||
599 | Minimum Index Sum of Two Lists | Solution | O(max(m,n)) | O(max(m,n)) | Easy | HashMap | |
600 | Non-negative Integers without Consecutive Ones | Solution | O(log2(max_int) = 32) | O(log2(max_int) = 32) | Hard | Bit Manipulation, DP | |
604 | Design Compressed String Iterator | Solution | O(n) | O(n) | Easy | Design, String | |
605 | Can Place Flowers | Solution | O(n) | O(1) | Easy | Array | |
606 | Construct String from Binary Tree | Solution | O(n) | O(n) | Easy | Tree, Recursion | |
609 | Find Duplicate File in System | Solution | O(n*x) (x is the average length of each string) | O(n*x) | Medium | HashMap | |
611 | Valid Triangle Number | Solution | O(n^2logn) | O(logn) | Medium | Binary Search | |
616 | Add Bold Tag in String | Solution | O(n*k) (n is length of string, k is size of dict) | O(n) | Medium | String | |
617 | Merge Two Binary Trees | Solution | O(n) | O(h) | Easy | Tree, Recursion | |
621 | Task Scheduler | Solution | O(n) | O(26) | Medium | Greedy, Queue | |
623 | Add One Row to Tree | Solution | O(n) | O(h) | Medium | Tree | |
624 | Maximum Distance in Arrays | Solution | O(nlogn) | O(1) | Easy | Sort, Array | |
625 | Minimum Factorization | Solution | O(?) | O(?) | Medium | ||
628 | Maximum Product of Three Numbers | Solution | O(nlogn) | O(1) | Easy | ||
629 | K Inverse Pairs Array | Solution | O(n*k) | O(n*k) | Hard | DP | |
630 | Course Schedule III | Solution | O(n*logn) | O(n) | Hard | Heap, Greedy | |
631 | Design Excel Sum Formula | Solution | Hard | Design, Topological Sort | |||
632 | Smallest Range | Solution | O(n*logk) | O(k) | Hard | Heap | |
633 | Sum of Square Numbers | Solution | O(logn) | O(1) | Easy | Binary Search | |
634 | Find the Derangement of An Array | Solution | O(n) | O(1) | Medium | Math | |
635 | Design Log Storage System | Solution | O(n) | O(n) | Medium | Design | |
636 | Exclusive Time of Functions | Solution | O(n) | O(n/2) | Medium | Stack | |
637 | Average of Levels in Binary Tree | Solution | O(n) | O(1) | Easy | ||
638 | Shopping Offers | Solution | O(2^n) | O(n) | Medium | DP, DFS | |
639 | Decode Ways II | Solution | O(n) | O(n) | Hard | DP | |
640 | Solve the Equation | Solution | O(n) | O(n) | Medium | ||
642 | Design Search Autocomplete System | Solution | O(n) | O(n) | Hard | Design | |
643 | Maximum Average Subarray I | Solution | O(n) | O(1) | Easy | ||
644 | Maximum Average Subarray II | Solution | O(1) | Hard | Binary Search | ||
645 | Set Mismatch | Solution | O(nlogn) | O(1) | Easy | ||
646 | Maximum Length of Pair Chain | Solution | O(nlogn) | O(1) | Medium | DP, Greedy | |
647 | Palindromic Substrings | Solution | O(n^2) | O(1) | Medium | DP | |
648 | Replace Words | Solution | O(n) | O(n) | Medium | Trie | |
649 | Dota2 Senate | Solution | O(n) | O(n) | Medium | Greedy | |
650 | 2 Keys Keyboard | Solution | O(n^2) | O(n) | Medium | DP | |
651 | 4 Keys Keyboard | Solution | O(n^2) | O(n) | Medium | DP | |
652 | Find Duplicate Subtrees | Solution | O(n) | O(n) | Medium | Tree | |
653 | Two Sum IV - Input is a BST | Solution | Easy | Tree | |||
654 | Maximum Binary Tree | Solution | O(n) | O(n) | Medium | Tree | |
655 | Print Binary Tree | Solution | O(h*2^h) | O(h*2^h) | Medium | Recursion | |
656 | Coin Path | Solution | O(n*B) | O(n) | Hard | DP | |
657 | Judge Route Circle | Solution | O(n) | O(1) | Easy | ||
658 | Find K Closest Elements | Solution | O(n) | O(1) | Medium | ||
659 | Split Array into Consecutive Subsequences | Solution | O(n) | O(n) | Medium | HashMap | |
660 | Remove 9 | Solution | O(n) | O(1) | Hard | Math | |
661 | Image Smoother | Solution | O(m*n) | O(1) | Easy | Array | |
662 | Maximum Width of Binary Tree | Solution | O(n) | O(k) | Medium | BFS, DFS | |
663 | Equal Tree Partition | Solution | O(n) | O(n) | Medium | Tree | |
664 | Strange Printer | Solution | O(n^3) | O(n^2) | Hard | DP | |
665 | Non-decreasing Array | Solution | O(n) | O(n) | Easy | ||
666 | Path Sum IV | Solution | O(1) | O(1) | Medium | Tree, DFS | |
667 | Beautiful Arrangement II | Solution | O(n) | O(1) | Medium | Array | |
668 | Kth Smallest Number in Multiplication Table | Solution | O(logm*n) | O(1) | Hard | Binary Search | |
669 | Trim a Binary Search Tree | Solution | O(n) | O(1) | Easy | Tree, DFS | |
670 | Maximum Swap | Solution | O(n^2) | O(1) | Medium | String | |
671 | Second Minimum Node In a Binary Tree | Solution | O(n) | O(n) | Easy | Tree, DFS | |
672 | Bulb Switcher II | Solution | O(1) | O(1) | Medium | Math | |
673 | Number of Longest Increasing Subsequence | Solution | O(n^2) | O(n) | Medium | DP | |
674 | Longest Continuous Increasing Subsequence | Solution | O(n^2) | O(1) | Easy | ||
675 | Cut Off Trees for Golf Event | Solution | O((m*n)^2) | O(m*n) | Hard | BFS | |
676 | Implement Magic Dictionary | Solution | O(n^2) | O(n) | Medium | ||
677 | Map Sum Pairs | Solution | O(n) | O(n) | Medium | HashMap | |
678 | Valid Parenthesis String | Solution | O(n) | O(1) | Medium | Recursion, Greedy | |
679 | 24 Game | Solution | O(1) (Upper bound 9216) | O(1) | Hard | Recursion | |
680 | Valid Palindrome II | Solution | O(n) | O(1) | Easy | String | |
681 | Next Closest Time | Solution | O(1) | O(1) | Medium | ||
682 | Baseball Game | Solution | O(n) | O(1) | Easy | ||
683 | K Empty Slots | Solution | O(n) | O(n) | Hard | ||
684 | Redundant Connection | Solution | O(n) | O(n) | Medium | Union Find | |
685 | Redundant Connection II | Solution | O(n) | O(n) | Hard | Union Find | |
686 | Repeated String Match | Solution | O(n*(m+n)) | O(m+n) | Easy | ||
687 | Longest Univalue Path | Solution | O(n) | O(h) | Easy | DFS | |
688 | Knight Probability in Chessboard | Solution | O(n^2) | O(n^2) | Medium | DP | |
689 | Maximum Sum of 3 Non-Overlapping Subarrays | Solution | O(n) | O(n) | Hard | DP | |
690 | Employee Importance | Solution | O(n) | O(h) | Easy | DFS | |
691 | Stickers to Spell Word | Solution | O(?) | O(?) | Hard | DP | |
692 | Top K Frequent Words | Solution | O(nlogk) | O(n) | Medium | ||
693 | Binary Number with Alternating Bits | Solution | O(n) | O(1) | Easy | ||
694 | Number of Distinct Islands | Solution | O(m*n) | O(1) | Medium | DFS | |
695 | Max Area of Island | Solution | O(m*n) | O(1) | Easy | DFS | |
696 | Count Binary Substrings | Solution | O(n) | O(n) | Easy | ||
697 | Degree of an Array | Solution | O(n) | O(n) | Easy | ||
698 | Partition to K Equal Sum Subsets | Solution | O(n*(2^n)) | O(2^n) | Medium | Backtracking | |
699 | Falling Squares | Solution | O(n^2) | O(n) | Hard | Segment Tree | |
712 | Minimum ASCII Delete Sum for Two Strings | Solution | O(m*n) | O(m*n) | Medium | DP | |
713 | Subarray Product Less Than K | Solution | O(n) | O(1) | Medium | ||
714 | Best Time to Buy and Sell Stock with Transaction Fee | Solution | O(n) | O(1) | Medium | DP | |
716 | Max Stack | Solution | O(logn) | O(n) | Hard | Design | |
717 | 1-bit and 2-bit Characters | Solution | O(n) | O(1) | Easy | ||
718 | Maximum Length of Repeated Subarray | Solution | O(m*n) | O(m*n) | Medium | DP | |
719 | Find K-th Smallest Pair Distance | Solution | O(nlogw + nlogn) | O(1) | Hard | Binary Search | |
720 | Longest Word in Dictionary | Solution | O(��wi) where wi is the length of words[i] | O(��wi) where wi is the length of words[i] | Easy | Trie | |
721 | Accounts Merge | Solution | Medium | DFS, Union Find | |||
723 | Candy Crush | Solution | O((r*c)^2) | O((r*c)) | Medium | Array, Two Pointers | |
724 | Find Pivot Index | Solution | O(n) | O(1) | Easy | Array | |
725 | Split Linked List in Parts | Solution | O(n+k) | O(k) | Medium | LinkedList | |
727 | Minimum Window Subsequence | Solution | O(m*n) | O(m*n) | Hard | DP | |
728 | Self Dividing Numbers | Solution | O(n*k) k is the average number of digits of each number in the given array | O(1) | Easy | ||
729 | My Calendar I | Solution | O(n) | O(n) | Medium | ||
733 | Flood Fill | Solution | O(m*n) | O(m*n) | Easy | BFS, DFS | |
734 | Sentence Similarity | Solution | O(n*k) | O(1) | Easy | HashTable | |
735 | Asteroid Collision | Solution | O(n) | O(n) | Medium | Stack | |
737 | Sentence Similarity II | Solution | O(nlogk + k) n is the length of max(words1, words2), k is the length of pairs | O(k) | Medium | Union Find | |
738 | Monotone Increasing Digits | Solution | O(n) | O(1) | Medium | ||
739 | Daily Temperatures | Solution | O(n^2) | O(1) | Medium | ||
740 | Delete and Earn | Solution | O(n) | O(n) | Medium | ||
744 | Find Smallest Letter Greater Than Target | Solution | O(logn) | O(1) | Easy | ||
746 | Min Cost Climbing Stairs | Solution | O(n) | O(1) | Easy | ||
747 | Largest Number Greater Than Twice of Others | Solution | O(n) | O(1) | Easy | ||
748 | Shortest Completing Word | Solution | O(n) | O(1) | Easy | ||
750 | Number Of Corner Rectangles | Solution | O((m*n)^2) | O(1) | Medium | ||
754 | Reach a Number | Solution | O(n) | O(1) | Medium | Math | |
755 | Pour Water | Solution | O(V*N) | O(1) | Medium | Array | |
756 | Pyramid Transition Matrix | Solution | O(?) | O(?) | Medium | Backtracking | |
758 | Bold Words in String | Solution | O(n*k) | O(n | Easy | ||
760 | Find Anagram Mappings | Solution | O(n^2) | O(1) | Easy | ||
762 | Prime Number of Set Bits in Binary Representation | Solution | O(n) | O(1) | Easy | ||
763 | Partition Labels | Solution | O(n) | O(1) | Medium | ||
764 | Largest Plus Sign | Solution | O(n^2) | O(n^2) | Medium | DP | |
765 | Couples Holding Hands | Solution | O(n^2) | O(1) | Hard |
Leetcode题解2
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...