LeetCode
Introduction
Algorithms
Depth-first Search
Breadth-first Search
Union Find
Tree
Dynamic Programming
Topological Sort
Substring Problem Template
Kadane's Algorithm
KMP
Fenwick Tree or Binary Indexed Tree
Segment Tree Range Minimum Query
Subset Sum
Sweep-line Algorithm
Expression Tree
Interval Search Tree
Monte Carlo Method
LeetCode
LeetCode Diary
1. Two Sum (Easy)
2. Add Two Numbers (Medium)
3. Longest Substring Without Repeating Characters (Medium)
4. Median of Two Sorted Arrays (Hard)
5. Longest Palindromic Substring (Medium)
10. Regular Expression Matching (Hard)
11. Container With Most Water (Medium)
14. Longest Common Prefix (Easy)
15. 3Sum (Medium)
17. Letter Combinations of a Phone Number (Medium)
20. Valid Parentheses (Easy)
21. Merge Two Sorted Lists (Easy)
22. Generate Parentheses (Medium)
23. Merge k Sorted Lists (Hard)
24. Swap Nodes in Pairs (Easy)
25. Reverse Nodes in k-Group (Hard)
28. Implement strStr() (Easy)
29. Divide Two Integers (Medium)
30. Substring with Concatenation of All Words (Hard)
31. Next Permutation (Medium)
32. Longest Valid Parentheses (Hard)
33. Search in Rotated Sorted Array (Medium)
36. Valid Sudoku (Medium)
37. Sudoku Solver (Hard)
39. Combination Sum (Medium)
40. Combination Sum II (Medium)
42. Trapping Rain Water (Hard)
43. Multiply Strings (Medium)
44. Wildcard Matching (Hard)
46. Permutations (Medium)
47. Permutations II (Medium)
49. Group Anagrams (Medium)
50. Pow(x, n) (Medium)
51. N-Queens (Hard)
52. N-Queens II (Hard)
53. Maximum Subarray(Easy)
54. Spiral Matrix (Medium)
55. Jump Game (Medium)
56. Merge Intervals (Hard)
57. Insert Interval (Hard)
60. Permutation Sequence (Medium)
62. Unique Paths (Medium)
63. Unique Paths II (Medium)
64. Minimum Path Sum (Medium)
66. Plus One (Easy)
69. Sqrt(x) (Easy)
71. Simplify Path (Medium)
72. Edit Distance (Hard)
74. Search a 2D Matrix
75. Sort Colors (Medium)
76. Minimum Window Substring (Hard)
77. Combinations (Medium)
78. Subsets (Medium)
79. Word Search (Medium)
84. Largest Rectangle in Histogram (Hard)
85. Maximal Rectangle (Hard)
88. Merge Sorted Array (Easy)
89. Gray Code (Medium)
90. Subsets II (Medium)
98. Validate Binary Search Tree (Medium)
103. Binary Tree Zigzag Level Order Traversal (Medium)
105. Construct Binary Tree from Preorder and Inorder Traversal (Medium)
116. Populating Next Right Pointers in Each Node (Medium)
117. Populating Next Right Pointers in Each Node II (Medium)
122. Best Time to Buy and Sell Stock II (Easy)
123. Best Time to Buy and Sell Stock III (Hard)
124. Binary Tree Maximum Path Sum (Hard)
126. Word Ladder II (Hard)
127. Word Ladder (Medium)
128. Longest Consecutive Sequence (Hard)
130. Surrounded Regions (Medium)
133. Clone Graph (Medium)
134. Gas Station (Medium)
138. Copy List with Random Pointer
139. Word Break (Medium)
140. Word Break II (Hard)
142. Linked List Cycle II (Medium)
144. Binary Tree Preorder Traversal (Medium)
145. Binary Tree Postorder Traversal (Hard)
146. LRU Cache (Hard)
150. Evaluate Reverse Polish Notation (Medium)
151. Reverse Words in a String (Medium)
152. Maximum Product Subarray (Medium)
155. Min Stack (Easy)
156. Binary Tree Upside Down (Medium)
157. Read N Characters Given Read4 (Easy)
158. Read N Characters Given Read4 II - Call multiple times (Hard)
159. Longest Substring with At Most Two Distinct Characters (Hard)
161. One Edit Distance (Medium)
162. Find Peak Element (Medium)
163. Missing Ranges (Medium)
165. Compare Version Numbers (Medium)
166. Fraction to Recurring Decimal (Medium)
167. Two Sum II - Input array is sorted (Easy)
170. Two Sum III - Data structure design (Easy)
173. Binary Search Tree Iterator (Medium)
186. Reverse Words in a String II (Medium)
188. Best Time to Buy and Sell Stock IV (Hard)
200. Number of Islands (Medium)
205. Isomorphic Strings (Easy)
207. Course Schedule (Medium)
208. Implement Trie (Prefix Tree) (Medium)
210. Course Schedule II (Medium)
211. Add and Search Word - Data structure design (Medium)
212. Word Search II (Hard)
214. Shortest Palindrome
215. Kth Largest Element in an Array (Medium)
216. Combination Sum III (Medium)
218. The Skyline Problem (Hard)
221. Maximal Square (Medium)
222. Count Complete Tree Nodes (Medium)
223. Rectangle Area
224. Basic Calculator (Hard)
227. Basic Calculator II (Medium)
228. Summary Ranges (Medium)
230. Kth Smallest Element in a BST (Medium)
231. Power of Two (Easy)
239. Sliding Window Maximum (Hard)
240. Search a 2D Matrix II
241. Different Ways to Add Parentheses (Medium)
242. Valid Anagram (Easy)
243. Shortest Word Distance (Easy)
244. Shortest Word Distance II (Medium)
245. Shortest Word Distance III (Medium)
246. Strobogrammatic Number (Easy)
247. Strobogrammatic Number II (Medium)
248. Strobogrammatic Number III (Hard)
249. Group Shifted Strings (Medium)
250. Count Univalue Subtrees (Medium)
251. Flatten 2D Vector (Medium)
252. Meeting Rooms (Easy)
253. Meeting Rooms II (Medium)
254. Factor Combinations (Medium)
255. Verify Preorder Sequence in Binary Search Tree (Medium)
256. Paint House (Easy)
257. Binary Tree Paths (Easy)
259. 3Sum Smaller (Medium)
261. Graph Valid Tree (Medium)
263. Ugly Number (Easy)
264. Ugly Number II (Medium)
265. Paint House II (Hard)
266. Palindrome Permutation (Easy)
267. Palindrome Permutation II (Medium)
268. Missing Number (Easy)
269. Alien Dictionary (Hard)
270. Closest Binary Search Tree Value (Easy)
271. Encode and Decode Strings (Medium)
272. Closest Binary Search Tree Value II (Hard)
273. Integer to English Words (Hard)
274. H-Index (Medium)
276. Paint Fence (Easy)
277. Find the Celebrity (Medium)
278. First Bad Version (Easy)
279. Perfect Squares (Medium)
280. Wiggle Sort (Medium)
281. Zigzag Iterator (Medium)
282. Expression Add Operators
284. Peeking Iterator (Medium)
285. Inorder Successor in BST (Medium)
286. Walls and Gates (Medium)
287. Find the Duplicate Number (Medium)
288. Unique Word Abbreviation (Easy)
289. Game of Life (Medium)
290. Word Pattern (Easy)
291. Word Pattern II (Hard)
293. Flip Game (Easy)
294. Flip Game II (Medium)
295. Find Median from Data Stream (Hard)
296. Best Meeting Point (Hard)
297. Serialize and Deserialize Binary Tree (Hard)
298. Binary Tree Longest Consecutive Sequence (Medium)
300. Longest Increasing Subsequence (Medium)
302. Smallest Rectangle Enclosing Black Pixels (Hard)
303. Range Sum Query - Immutable (Easy)
304. Range Sum Query 2D - Immutable (Medium)
305. Number of Islands II (Hard)
307. Range Sum Query - Mutable (Medium)
308. Range Sum Query 2D - Mutable (Hard)
309. Best Time to Buy and Sell Stock with Cooldown
310. Minimum Height Trees (Medium)
311. Sparse Matrix Multiplication (Medium)
312. Burst Balloons (Hard)
313. Super Ugly Number (Medium)
314. Binary Tree Vertical Order Traversal (Medium)
315. Count of Smaller Numbers After Self
316. Remove Duplicate Letters (Hard)
317. Shortest Distance from All Buildings (Hard)
318. Maximum Product of Word Lengths
320. Generalized Abbreviation (Medium)
321. Create Maximum Number (Hard)
322. Coin Change (Medium)
323. Number of Connected Components in an Undirected Graph (Medium)
324. Wiggle Sort II
325. Maximum Size Subarray Sum Equals k (Medium)
326. Power of Three (Easy)
327. Count of Range Sum
329. Longest Increasing Path in a Matrix (Hard)
330. Patching Array (Hard)
331. Verify Preorder Serialization of a Binary Tree (Medium)
332. Reconstruct Itinerary
333. Largest BST Subtree (Medium)
335. Self Crossing (Hard)
336. Palindrome Pairs
339. Nested List Weight Sum (Easy)
340. Longest Substring with At Most K Distinct Characters (Hard)
341. Flatten Nested List Iterator
342. Power of Four (Easy)
345. Reverse Vowels of a String (Easy)
346. Moving Average from Data Stream (Easy)
347. Top K Frequent Elements (Medium)
348. Design Tic-Tac-Toe (Medium)
351. Android Unlock Patterns (Medium)
353. Design Snake Game (Medium)
354. Russian Doll Envelopes (Hard)
356. Line Reflection (Medium)
357. Count Numbers with Unique Digits (Medium)
358. Rearrange String k Distance Apart (Hard)
359. Logger Rate Limiter (Easy)
360. Sort Transformed Array (Medium)
361. Bomb Enemy (Medium)
362. Design Hit Counter (Medium)
363. Max Sum of Rectangle No Larger Than K (Hard)
364. Nested List Weight Sum II (Medium)
366. Find Leaves of Binary Tree (Medium)
368. Largest Divisible Subset (Medium)
369. Plus One Linked List (Medium)
370. Range Addition (Medium)
372. Super Pow (Medium)
373. Find K Pairs with Smallest Sums
374. Guess Number Higher or Lower (Easy)
375. Guess Number Higher or Lower II(Medium)
377. Combination Sum IV (Medium)
378. Kth Smallest Element in a Sorted Matrix (Medium)
379. Design Phone Directory (Medium)
380. Insert Delete GetRandom O(1)
381 Insert Delete GetRandom O(1) - Duplicates allowed Hard-duplicates-allowed-hard.md)
382. Linked List Random Node (Medium)
385. Mini Parser (Medium)
387. First Unique Character in a String (Easy)
388. Longest Absolute File Path (Medium)
389. Find the Difference
391. Perfect Rectangle
393. UTF-8 Validation
394. Decode String (Medium)
397. Integer Replacement (Medium)
399. Evaluate Division (Medium)
400. Nth Digit (Easy)
401. Binary Watch (Easy)
402. Remove K Digits (Medium)
406. Queue Reconstruction by Height
407. Trapping Rain Water II
408. Valid Word Abbreviation (Easy)
409. Longest Palindrome
411. Minimum Unique Word Abbreviation (Hard)
412. Fizz Buzz (Easy)
415. Add Strings (Easy)
416. Partition Equal Subset Sum (Medium)
417. Pacific Atlantic Water Flow (Medium)
418. Sentence Screen Fitting (Medium)
419. Battleships in a Board (Medium)
420. Strong Password Checker (Hard)
421. Maximum XOR of Two Numbers in an Array (Medium)
422. Valid Word Square (Easy)
423. Reconstruct Original Digits from English (Medium)
425. Word Squares (Hard)
434. Number of Segments in a String (Easy)
435. Non-overlapping Intervals (Medium)
439. Ternary Expression Parser (Medium)
444. Sequence Reconstruction (Medium)
445. Add Two Numbers II (Medium)
447. Number of Boomerangs (Easy)
448. Find All Numbers Disappeared in an Array(Easy)
451. Sort Characters By Frequency (Medium)
456. 132 Pattern (Medium)
458. Poor Pigs (Easy)
459. Repeated Substring Pattern (Easy)
460. LFU Cache (Hard)
461. Hamming Distance (Easy)
463. Island Perimeter (Easy)
465. Optimal Account Balancing (Hard)
468. Validate IP Address (Medium)
469. Convex Polygon (Medium)
471. Encode String with Shortest Length (Hard)
472. Concatenated Words (Hard)
474. Ones and Zeroes (Medium)
475. Heaters (Easy)
477. Total Hamming Distance (Medium)
480. Sliding Window Median (Hard)
481. Magical String (Medium)
482. License Key Formatting (Medium)
483. Smallest Good Base (Hard)
484. Find Permutation (Medium)
485. Max Consecutive Ones (Easy)
486. Predict the Winner (Medium)
487. Max Consecutive Ones II (Medium)
490. The Maze (Medium)
494. Target Sum (Medium)
496. Next Greater Element I (Easy)
498. Diagonal Traverse (Medium)
499. The Maze III (Hard)
501. Find Mode in Binary Search Tree (Easy)
503. Next Greater Element II (Medium)
505. The Maze II (Medium)
506. Relative Ranks (Easy)
507. Perfect Number (Easy)
514. Freedom Trail (Hard)
523. Continuous Subarray Sum (Medium)
524. Longest Word in Dictionary through Deleting (Medium)
526. Beautiful Arrangement (Medium)
529. Minesweeper (Medium)
530. Minimum Absolute Difference in BST (Easy)
531. Lonely Pixel I (Medium)
532. K-diff Pairs in an Array (Easy)
533. Lonely Pixel II (Medium)
534. Design TinyURL (Medium)
535. Encode and Decode TinyURL (Medium)
536. Construct Binary Tree from String (Medium)
538. Convert BST to Greater Tree (Easy)
539. Minimum Time Difference (Medium)
541. Reverse String II (Easy)
542. 01 Matrix (Medium)
543. Diameter of Binary Tree (Easy)
544. Output Contest Matches (Medium)
545. Boundary of Binary Tree (Medium)
546. Remove Boxes (Hard)
334 Increasing Triplet Subsequence Medium
527 Word Abbreviation Hard
537 Complex Number Multiplication Medium
99 Recover Binary Search Tree Hard
68 Text Justification Hard
95 Unique Binary Search Trees II Medium
87 Scramble String Hard
521 Longest Uncommon Subsequence I Easy
522 Longest Uncommon Subsequence II Medium
547 Friend Circles Medium
548 Split Array with Equal Sum Medium
Powered by
GitBook
Depth-first Search
Depth-first Search
recursive: do-able
iterative: use stack
results matching "
"
No results matching "
"