Leetcode
Master algorithms and data structures with 244 carefully curated problems
Categories
97. Interleaving String
Explore this comprehensive solution with detailed explanations and multiple approaches.
Categories
All Articles
97. Interleaving String
Comprehensive solution with detailed explanations and multiple approaches.
670. Maximum Swap
Comprehensive solution with detailed explanations and multiple approaches.
1570. Dot Product of Two Sparse Vectors
Comprehensive solution with detailed explanations and multiple approaches.
93. Restore IP Addresses
Comprehensive solution with detailed explanations and multiple approaches.
616. Add Bold Tag in String
Comprehensive solution with detailed explanations and multiple approaches.
678. Valid Parenthesis String
Comprehensive solution with detailed explanations and multiple approaches.
691. Stickers to Spell Words
Comprehensive solution with detailed explanations and multiple approaches.
2. Add Two Numbers
Comprehensive solution with detailed explanations and multiple approaches.
3. Longest Substring Without Repeating Characters
Comprehensive solution with detailed explanations and multiple approaches.
3. Longest Substring Without Repeating Characters
Comprehensive solution with detailed explanations and multiple approaches.
4. Median of Two Sorted Arrays
Comprehensive solution with detailed explanations and multiple approaches.
5. Longest Palindromic Substring
Comprehensive solution with detailed explanations and multiple approaches.
6. Zigzag Conversion
Comprehensive solution with detailed explanations and multiple approaches.
9. Palindrome Number
Comprehensive solution with detailed explanations and multiple approaches.
11. Container With Most Water
Comprehensive solution with detailed explanations and multiple approaches.
12. Integer to Roman
Comprehensive solution with detailed explanations and multiple approaches.
13. Roman to Integer
Comprehensive solution with detailed explanations and multiple approaches.
14. Longest Common Prefix
Comprehensive solution with detailed explanations and multiple approaches.
17. Letter Combinations of a Phone Number
Comprehensive solution with detailed explanations and multiple approaches.
19. Remove Nth Node From End of List
Comprehensive solution with detailed explanations and multiple approaches.
20. Valid Parentheses
Comprehensive solution with detailed explanations and multiple approaches.
21. Merge Two Sorted Lists
Comprehensive solution with detailed explanations and multiple approaches.
22. Generate Parentheses
Comprehensive solution with detailed explanations and multiple approaches.
23. Merge k Sorted Lists
Comprehensive solution with detailed explanations and multiple approaches.
24. Swap Nodes in Pairs
Comprehensive solution with detailed explanations and multiple approaches.
25. Reverse Nodes in k-Group
Comprehensive solution with detailed explanations and multiple approaches.
26. Remove Duplicates from Sorted Array
Comprehensive solution with detailed explanations and multiple approaches.
27. Remove Element
Comprehensive solution with detailed explanations and multiple approaches.
28. Find the Index of the First Occurrence in a String
Comprehensive solution with detailed explanations and multiple approaches.
30. Substring with Concatenation of All Words
Comprehensive solution with detailed explanations and multiple approaches.
31. Next Permutation
Comprehensive solution with detailed explanations and multiple approaches.
33. Search in Rotated Sorted Array
Comprehensive solution with detailed explanations and multiple approaches.
34. Find First and Last Position of Element in Sorted Array
Comprehensive solution with detailed explanations and multiple approaches.
35. Search Insert Position
Comprehensive solution with detailed explanations and multiple approaches.
36. Valid Sudoku
Comprehensive solution with detailed explanations and multiple approaches.
39. Combination Sum
Comprehensive solution with detailed explanations and multiple approaches.
40. Combination Sum II
Comprehensive solution with detailed explanations and multiple approaches.
42. Trapping Rain Wate
Comprehensive solution with detailed explanations and multiple approaches.
45. Jump Game II
Comprehensive solution with detailed explanations and multiple approaches.
46. Permutations
Comprehensive solution with detailed explanations and multiple approaches.
48. Rotate Image
Comprehensive solution with detailed explanations and multiple approaches.
49. Group Anagrams
Comprehensive solution with detailed explanations and multiple approaches.
50. Pow(x, n)
Comprehensive solution with detailed explanations and multiple approaches.
51. N-Queens
Comprehensive solution with detailed explanations and multiple approaches.
52. N-Queens II
Comprehensive solution with detailed explanations and multiple approaches.
53. Maximum Subarray
Comprehensive solution with detailed explanations and multiple approaches.
54. Spiral Matrix
Comprehensive solution with detailed explanations and multiple approaches.
55. Jump Game
Comprehensive solution with detailed explanations and multiple approaches.
56. Merge Intervals
Comprehensive solution with detailed explanations and multiple approaches.
57. Insert Interval
Comprehensive solution with detailed explanations and multiple approaches.
58. Length of Last Word
Comprehensive solution with detailed explanations and multiple approaches.
61. Rotate List
Comprehensive solution with detailed explanations and multiple approaches.
62. Unique Paths
Comprehensive solution with detailed explanations and multiple approaches.
63. Unique Paths II
Comprehensive solution with detailed explanations and multiple approaches.
64. Minimum Path Sum
Comprehensive solution with detailed explanations and multiple approaches.
66. Plus One
Comprehensive solution with detailed explanations and multiple approaches.
68. Text Justification
Comprehensive solution with detailed explanations and multiple approaches.
69. Sqrt(x)
Comprehensive solution with detailed explanations and multiple approaches.
70. Climbing Stairs
Comprehensive solution with detailed explanations and multiple approaches.
71. Simplify Path
Comprehensive solution with detailed explanations and multiple approaches.
73. Set Matrix Zeroes
Comprehensive solution with detailed explanations and multiple approaches.
74. Search a 2D Matrix
Comprehensive solution with detailed explanations and multiple approaches.
76. Minimum Window Substring
Comprehensive solution with detailed explanations and multiple approaches.
77. Combinations
Comprehensive solution with detailed explanations and multiple approaches.
79. Word Search
Comprehensive solution with detailed explanations and multiple approaches.
80. Remove Duplicates from Sorted Array II
Comprehensive solution with detailed explanations and multiple approaches.
82. Remove Duplicates from Sorted List II
Comprehensive solution with detailed explanations and multiple approaches.
86. Partition List
Comprehensive solution with detailed explanations and multiple approaches.
88. Merge Sorted Array
Comprehensive solution with detailed explanations and multiple approaches.
91. Decode Ways
Comprehensive solution with detailed explanations and multiple approaches.
92. Reverse Linked List II
Comprehensive solution with detailed explanations and multiple approaches.
96. Unique Binary Search Trees
Comprehensive solution with detailed explanations and multiple approaches.
98. Validate Binary Search Tree
Comprehensive solution with detailed explanations and multiple approaches.
100. Same Tree
Comprehensive solution with detailed explanations and multiple approaches.
101. Symmetric Tree
Comprehensive solution with detailed explanations and multiple approaches.
102. Binary Tree Level Order Traversal
Comprehensive solution with detailed explanations and multiple approaches.
103. Binary Tree Zigzag Level Order Traversal
Comprehensive solution with detailed explanations and multiple approaches.
104. Maximum Depth of Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
105. Construct Binary Tree from Preorder and Inorder Traversal
Comprehensive solution with detailed explanations and multiple approaches.
106. Construct Binary Tree from Inorder and Postorder Traversal
Comprehensive solution with detailed explanations and multiple approaches.
108. Convert Sorted Array to Binary Search Tree
Comprehensive solution with detailed explanations and multiple approaches.
112. Path Sum
Comprehensive solution with detailed explanations and multiple approaches.
114. Flatten Binary Tree to Linked List
Comprehensive solution with detailed explanations and multiple approaches.
117. Populating Next Right Pointers in Each Node II
Comprehensive solution with detailed explanations and multiple approaches.
120. Triangle
Comprehensive solution with detailed explanations and multiple approaches.
121. Best Time to Buy and Sell Stock
Comprehensive solution with detailed explanations and multiple approaches.
122. Best Time to Buy and Sell Stock II
Comprehensive solution with detailed explanations and multiple approaches.
124. Binary Tree Maximum Path Sum
Comprehensive solution with detailed explanations and multiple approaches.
125. Valid Palindrome
Comprehensive solution with detailed explanations and multiple approaches.
127. Word Ladder
Comprehensive solution with detailed explanations and multiple approaches.
128. Longest Consecutive Sequence
Comprehensive solution with detailed explanations and multiple approaches.
129. Sum Root to Leaf Numbers
Comprehensive solution with detailed explanations and multiple approaches.
130. Surrounded Regions
Comprehensive solution with detailed explanations and multiple approaches.
133. Clone Graph
Comprehensive solution with detailed explanations and multiple approaches.
134. Gas Station
Comprehensive solution with detailed explanations and multiple approaches.
135. Candy
Comprehensive solution with detailed explanations and multiple approaches.
136. Single Number
Comprehensive solution with detailed explanations and multiple approaches.
137. Single Number II
Comprehensive solution with detailed explanations and multiple approaches.
138. Copy List with Random Pointer
Comprehensive solution with detailed explanations and multiple approaches.
139. Word Break
Comprehensive solution with detailed explanations and multiple approaches.
140. Word Break ii - Test kĩ năng DP và Trie
Comprehensive solution with detailed explanations and multiple approaches.
141. Linked List Cycle
Comprehensive solution with detailed explanations and multiple approaches.
143. Reorder List
Comprehensive solution with detailed explanations and multiple approaches.
146. LRU Cache
Comprehensive solution with detailed explanations and multiple approaches.
148. Sort List
Comprehensive solution with detailed explanations and multiple approaches.
149. Max Points on a Line
Comprehensive solution with detailed explanations and multiple approaches.
150. Evaluate Reverse Polish Notation
Comprehensive solution with detailed explanations and multiple approaches.
151. Reverse Words in a String
Comprehensive solution with detailed explanations and multiple approaches.
152. Maximum Product Subarray
Comprehensive solution with detailed explanations and multiple approaches.
153. Find Minimum in Rotated Sorted Array
Comprehensive solution with detailed explanations and multiple approaches.
155. Min Stack
Comprehensive solution with detailed explanations and multiple approaches.
162. Find Peak Element
Comprehensive solution with detailed explanations and multiple approaches.
169. Majority Element
Comprehensive solution with detailed explanations and multiple approaches.
172. Factorial Trailing Zeroes
Comprehensive solution with detailed explanations and multiple approaches.
173. Binary Search Tree Iterator
Comprehensive solution with detailed explanations and multiple approaches.
189. Rotate Array
Comprehensive solution with detailed explanations and multiple approaches.
190. Reverse Bits
Comprehensive solution with detailed explanations and multiple approaches.
191. Number of 1 Bits
Comprehensive solution with detailed explanations and multiple approaches.
198. House Robber
Comprehensive solution with detailed explanations and multiple approaches.
199. Binary Tree Right Side View
Comprehensive solution with detailed explanations and multiple approaches.
200. Number of Islands
Comprehensive solution with detailed explanations and multiple approaches.
201. Bitwise AND of Numbers Range
Comprehensive solution with detailed explanations and multiple approaches.
202. Happy Number
Comprehensive solution with detailed explanations and multiple approaches.
205. Isomorphic Strings
Comprehensive solution with detailed explanations and multiple approaches.
206. Reverse Linked List
Comprehensive solution with detailed explanations and multiple approaches.
207. Course Schedule
Comprehensive solution with detailed explanations and multiple approaches.
209. Minimum Size Subarray Sum
Comprehensive solution with detailed explanations and multiple approaches.
211. Design Add and Search Words Data Structure
Comprehensive solution with detailed explanations and multiple approaches.
212. Word Search II
Comprehensive solution with detailed explanations and multiple approaches.
213. House Robber II
Comprehensive solution with detailed explanations and multiple approaches.
215. Kth Largest Element in an Array
Comprehensive solution with detailed explanations and multiple approaches.
217. Contains Duplicate
Comprehensive solution with detailed explanations and multiple approaches.
219. Contains Duplicate II
Comprehensive solution with detailed explanations and multiple approaches.
221. Maximal Square
Comprehensive solution with detailed explanations and multiple approaches.
222. Count Complete Tree Nodes
Comprehensive solution with detailed explanations and multiple approaches.
224. Basic calculator
Comprehensive solution with detailed explanations and multiple approaches.
226. Invert Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
228. Summary Ranges
Comprehensive solution with detailed explanations and multiple approaches.
230. Kth Smallest Element in a BST
Comprehensive solution with detailed explanations and multiple approaches.
235. Lowest Common Ancestor of a Binary Search Tree
Comprehensive solution with detailed explanations and multiple approaches.
236. Lowest Common Ancestor of a Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
238. Product of Array Except Self
Comprehensive solution with detailed explanations and multiple approaches.
239. Sliding window maximum
Comprehensive solution with detailed explanations and multiple approaches.
242. Valid Anagram
Comprehensive solution with detailed explanations and multiple approaches.
252. Meeting Rooms
Comprehensive solution with detailed explanations and multiple approaches.
253. Meeting Rooms II
Comprehensive solution with detailed explanations and multiple approaches.
261. Graph valid tree
Comprehensive solution with detailed explanations and multiple approaches.
268. Missing Number
Comprehensive solution with detailed explanations and multiple approaches.
269. Alien Dictionary
Comprehensive solution with detailed explanations and multiple approaches.
271. Encode and Decode Strings
Comprehensive solution with detailed explanations and multiple approaches.
274. H-Index
Comprehensive solution with detailed explanations and multiple approaches.
286. Wall and gates
Comprehensive solution with detailed explanations and multiple approaches.
287. Find the Duplicate Number
Comprehensive solution with detailed explanations and multiple approaches.
289. Game of Life
Comprehensive solution with detailed explanations and multiple approaches.
290. Word Pattern
Comprehensive solution with detailed explanations and multiple approaches.
295. Find Median from Data Stream
Comprehensive solution with detailed explanations and multiple approaches.
297. Serialize and Deserialize Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
300. Longest Increasing Subsequence
Comprehensive solution with detailed explanations and multiple approaches.
309. Best Time to Buy and Sell Stock with Cooldown
Comprehensive solution with detailed explanations and multiple approaches.
317. Shortest Distance from All Buildings
Comprehensive solution with detailed explanations and multiple approaches.
322. Coin Change
Comprehensive solution with detailed explanations and multiple approaches.
323. Number of Connected Components in an Undirected Graph
Comprehensive solution with detailed explanations and multiple approaches.
329. Longest Increasing Path in a Matrix
Comprehensive solution with detailed explanations and multiple approaches.
337. House Robber III
Comprehensive solution with detailed explanations and multiple approaches.
338. Counting Bits
Comprehensive solution with detailed explanations and multiple approaches.
347. Top K Frequent Elements
Comprehensive solution with detailed explanations and multiple approaches.
365. Water and Jug Problem
Comprehensive solution with detailed explanations and multiple approaches.
371. Sum of Two Integers
Comprehensive solution with detailed explanations and multiple approaches.
373. Find K Pairs with Smallest Sums
Comprehensive solution with detailed explanations and multiple approaches.
377. Combination Sum IV
Comprehensive solution with detailed explanations and multiple approaches.
378. Kth Smallest Element in a Sorted Matrix
Comprehensive solution with detailed explanations and multiple approaches.
380. Insert Delete GetRandom O(1)
Comprehensive solution with detailed explanations and multiple approaches.
380. Insert Delete GetRandom O(1)
Comprehensive solution with detailed explanations and multiple approaches.
383. Ransom Note
Comprehensive solution with detailed explanations and multiple approaches.
386. Lexicographical Numbers
Comprehensive solution with detailed explanations and multiple approaches.
392. Is Subsequence
Comprehensive solution with detailed explanations and multiple approaches.
395. Longest Substring with At Least K Repeating Characters
Comprehensive solution with detailed explanations and multiple approaches.
399. Evaluate Division
Comprehensive solution with detailed explanations and multiple approaches.
407. Trapping Rain Water II
Comprehensive solution with detailed explanations and multiple approaches.
415. Add Strings
Comprehensive solution with detailed explanations and multiple approaches.
416. Partition Equal Subset Sum
Comprehensive solution with detailed explanations and multiple approaches.
417. Pacific Atlantic Water Flow
Comprehensive solution with detailed explanations and multiple approaches.
424. Longest Repeating Character Replacement
Comprehensive solution with detailed explanations and multiple approaches.
427. Construct Quad Tree
Comprehensive solution with detailed explanations and multiple approaches.
433. Minimum Genetic Mutation
Comprehensive solution with detailed explanations and multiple approaches.
435. Non-overlapping Intervals
Comprehensive solution with detailed explanations and multiple approaches.
452. Minimum Number of Arrows to Burst Balloons
Comprehensive solution with detailed explanations and multiple approaches.
473. Matchsticks to Square
Comprehensive solution with detailed explanations and multiple approaches.
528. Random Pick with Weight
Comprehensive solution with detailed explanations and multiple approaches.
530. Minimum Absolute Difference in BST
Comprehensive solution with detailed explanations and multiple approaches.
543. Diameter of Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
560. Subarray Sum Equals K
Comprehensive solution with detailed explanations and multiple approaches.
567. Permutation in String
Comprehensive solution with detailed explanations and multiple approaches.
572. Subtree of Another Tree
Comprehensive solution with detailed explanations and multiple approaches.
637. Average of Levels in Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
647. Palindromic Substrings
Comprehensive solution with detailed explanations and multiple approaches.
648. Replace Words
Comprehensive solution with detailed explanations and multiple approaches.
680. Valid Palindrome II
Comprehensive solution with detailed explanations and multiple approaches.
694. Number of distinct Islands
Comprehensive solution with detailed explanations and multiple approaches.
695. Max Area of Island
Comprehensive solution with detailed explanations and multiple approaches.
735. Asteroid Collision
Comprehensive solution with detailed explanations and multiple approaches.
739. Daily Temperatures
Comprehensive solution with detailed explanations and multiple approaches.
752. Open the Lock
Comprehensive solution with detailed explanations and multiple approaches.
767. Reorganize String
Comprehensive solution with detailed explanations and multiple approaches.
772. Basic Calculator III
Comprehensive solution with detailed explanations and multiple approaches.
783. Minimum Distance Between BST Nodes
Comprehensive solution with detailed explanations and multiple approaches.
785. Is Graph Bipartite?
Comprehensive solution with detailed explanations and multiple approaches.
815. Bus Routes
Comprehensive solution with detailed explanations and multiple approaches.
856. Score of Parentheses
Comprehensive solution with detailed explanations and multiple approaches.
863. All Nodes Distance K in Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
875. Koko Eating Bananas
Comprehensive solution with detailed explanations and multiple approaches.
909. Snakes and Ladders
Comprehensive solution with detailed explanations and multiple approaches.
918. Maximum Sum Circular Subarray
Comprehensive solution with detailed explanations and multiple approaches.
934. Shortest Bridge
Comprehensive solution with detailed explanations and multiple approaches.
962. Maximum Width Ramp
Comprehensive solution with detailed explanations and multiple approaches.
981. Time Based Key-Value Store
Comprehensive solution with detailed explanations and multiple approaches.
1004. Max Consecutive Ones III
Comprehensive solution with detailed explanations and multiple approaches.
1010. Pairs of Songs With Total Durations Divisible by 60
Comprehensive solution with detailed explanations and multiple approaches.
1143. Longest Common Subsequence
Comprehensive solution with detailed explanations and multiple approaches.
1245. Tree Diameter
Comprehensive solution with detailed explanations and multiple approaches.
1268. Search Suggestions System
Comprehensive solution with detailed explanations and multiple approaches.
1293. Shortest Path in a Grid with Obstacles Elimination
Comprehensive solution with detailed explanations and multiple approaches.
1423. Maximum Points You Can Obtain from Cards
Comprehensive solution with detailed explanations and multiple approaches.
1466. Reorder Routes to Make All Paths Lead to the City Zero
Comprehensive solution with detailed explanations and multiple approaches.
1530. Number of Good Leaf Nodes Pairs
Comprehensive solution with detailed explanations and multiple approaches.
1539. Kth Missing Positive Number
Comprehensive solution with detailed explanations and multiple approaches.
1584. Min Cost to Connect All Points
Comprehensive solution with detailed explanations and multiple approaches.
1642. Furthest Building You Can Reach
Comprehensive solution with detailed explanations and multiple approaches.
1802. Maximum Value at a Given Index in a Bounded Array
Comprehensive solution with detailed explanations and multiple approaches.
1813. Sentence Similarity III
Comprehensive solution with detailed explanations and multiple approaches.
2402. Meeting Rooms III
Comprehensive solution with detailed explanations and multiple approaches.
2422. Merge Operations to Turn Array Into a Palindrome
Comprehensive solution with detailed explanations and multiple approaches.
2673. Make Costs of Paths Equal in a Binary Tree
Comprehensive solution with detailed explanations and multiple approaches.
2850. Minimum Moves to Spread Stones Over Grid
Comprehensive solution with detailed explanations and multiple approaches.
2931. Maximum Spending After Buying Items
Comprehensive solution with detailed explanations and multiple approaches.
3043. Find the Length of the Longest Common Prefix
Comprehensive solution with detailed explanations and multiple approaches.
Comprehensive solution with detailed explanations and multiple approaches.
2334. Subarray With Elements Greater Than Varying Threshold
Comprehensive solution with detailed explanations and multiple approaches.
3Sum
Comprehensive solution with detailed explanations and multiple approaches.
Coin change - bài toán kinh điển về DP
Comprehensive solution with detailed explanations and multiple approaches.
Decode a string
Comprehensive solution with detailed explanations and multiple approaches.
Design a Tic-Tac-Toe
Comprehensive solution with detailed explanations and multiple approaches.
Remove invalid parentheses
Comprehensive solution with detailed explanations and multiple approaches.
Subset
Comprehensive solution with detailed explanations and multiple approaches.