- Tried to use optimal solutions as much as I can. Most solutions are from the LeetCode community.
- Written in Airbnb JavaScript style.
- A work in progress.
- If you find something wrong or the complexity is not good, you are very welcome to contribute your better solutions.
- 7. Reverse Integer - Solution
- 8. String to Integer (atoi) - Solution
- 9. Palindrome Number - Solution
- 13. Roman to Integer - Solution
- 14. Longest Common Prefix - Solution
- 19. Remove Nth Node From End of List - Solution
- 20. Valid Parentheses - Solution
- 21. Merge Two Sorted Lists - Solution
- 24. Swap Nodes in Pairs - Solution
- 28. Implement strStr() - Solution
- 26. Remove Duplicates from Sorted Array - Solution
- 27. Remove Element - Solution
- 36. Valid Sudoku - Solution
- 38. Count and Say - Solution
- 53. Maximum Subarray - Solution
- 66. Plus One - Solution
- 67. Add Binary - Solution
- 70. Climbing Stairs - Solution
- 83. Remove Duplicates from Sorted List - Solution
- 88. Merge Sorted Array - Solution
- 100. Same Tree - Solution
- 101. Symmetric Tree - Solution
- 102. Binary Tree Level Order Traversal - Solution
- 104. Maximum Depth of Binary Tree - Solution
- 107. Binary Tree Level Order Traversal II - Solution
- 110. Balanced Binary Tree - Solution
- 111. Minimum Depth of Binary Tree - Solution
- 112. Path Sum - Solution
- 118. Pascal's Triangle - Solution
- 119. Pascal's Triangle II - Solution
- 125. Valid Palindrome - Solution
- 160. Intersection of Two Linked Lists - Solution
- 165. Compare Version Numbers - Solution
- 167. Two Sum II - Input array is sorted - Solution
- 169. Majority Element - Solution
- 172. Factorial Trailing Zeroes - Solution
- 190. Reverse Bits - Solution
- 191. Number of 1 Bits - Solution
- 198. House Robber - Solution
- 202. Happy Number - Solution
- 203. Remove Linked List Elements - Solution
- 204. Count Primes - Solution
- 205. Isomorphic Strings - Solution
- 206. Reverse Linked List - Solution
- 217. Contains Duplicate - Solution
- 219. Contains Duplicate II - Solution
- 223. Rectangle Area - Solution
- 225. Implement Stack using Queues - Solution
- 226. Invert Binary Tree - Solution
- 228. Summary Ranges - Solution
- 231. Power of Two - Solution
- 232. Implement Queue using Stacks - Solution
- 234. Palindrome Linked List - Solution
- 235. Lowest Common Ancestor of a Binary Search Tree - Solution
- 237. Delete Node in a Linked List - Solution
- 242. Valid Anagram - Solution
- 243. Shortest Word Distance - Solution
- 258. Add Digits - Solution
- 263. Ugly Number - Solution
- 278. First Bad Version - Solution
- 283. Move Zeroes - Solution
- 290. Word Pattern - Solution
- 299. Bulls and Cows - Solution
- 303. Range Sum Query - Immutable - Solution
- 326. Power of Three - Solution
- 328. Odd Even Linked List - Solution
- 342. Power of Four - Solution
- 344. Reverse String - Solution
- 349. Intersection of Two Arrays - Solution
- 350. Intersection of Two Arrays II - Solution
- 367. Valid Perfect Square - Solution
- 412. Fizz Buzz - Solution
- 1. Two Sum - Solution
- 2. Add Two Numbers - Solution
- 3. Longest Substring Without Repeating Characters - Solution
- 5. Longest Palindromic Substring - Solution
- 11. Container With Most Water - Solution
- 12. Integer to Roman - Solution
- 15. 3Sum - Solution
- 16. 3Sum Closest - Solution
- 17. Letter Combinations of a Phone Number - Solution
- 22. Generate Parentheses - Solution
- 29. Divide Two Integers - Solution
- 31. Next Permutation - Solution
- 31. Next Permutation - Solution
- 33. Search in Rotated Sorted Array - Solution
- 34. Search for a Range - Solution
- 39. Combination Sum - Solution
- 40. Combination Sum II - Solution
- 43. Multiply Strings - Solution
- 46. Permutations - Solution
- 47. Permutations II - Solution
- 48. Rotate Image - Solution
- 49. Group Anagrams - Solution
- 50. Pow(x, n) - Solution
- 54. Spiral Matrix - Solution
- 55. Jump Game - Solution
- 59. Spiral Matrix II - Solution
- 60. Permutation Sequence - Solution
- 61. Rotate List - Solution
- 62. Unique Paths - Solution
- 63. Unique Paths II - Solution
- 64. Minimum Path Sum - Solution
- 69. Sqrt(x) - Solution
- 71. Simplify Path - Solution
- 73. Set Matrix Zeroes - Solution
- 74. Search a 2D Matrix - Solution
- 75. Sort Colors - Solution
- 77. Combinations - Solution
- 78. Subsets - Solution
- 79. Word Search - Solution
- 80. Remove Duplicates from Sorted Array II - Solution
- 81. Search in Rotated Sorted Array II - Solution
- 82. Remove Duplicates from Sorted List II - Solution
- 86. Partition List - Solution
- 89. Gray Code - Solution
- 90. Subsets II - Solution
- 91. Decode Ways - Solution
- 92. Reverse Linked List II - Solution
- 93. Restore IP Addresses - Solution
- 94. Binary Tree Inorder Traversal - Solution
- 96. Unique Binary Search Trees - Solution
- 98. Validate Binary Search Tree - Solution
- 103. Binary Tree Zigzag Level Order Traversal - Solution
- 105. Construct Binary Tree from Preorder and Inorder Traversal - Solution
- 106. Construct Binary Tree from Inorder and Postorder Traversal - Solution
- 108. Convert Sorted Array to Binary Search Tree - Solution
- 109. Convert Sorted List to Binary Search Tree - Solution
- 113. Path Sum II - Solution
- 114. Flatten Binary Tree to Linked List - Solution
- 116. Populating Next Right Pointers in Each Node - Solution
- 120. Triangle - Solution
- 121. Best Time to Buy and Sell Stock - Solution
- 122. Best Time to Buy and Sell Stock II - Solution
- 129. Sum Root to Leaf Numbers - Solution
- 127. Word Ladder - Solution
- 130. Surrounded Regions - Solution
- 131. Palindrome Partitioning - Solution
- 134. Gas Station - Solution
- 136. Single Number - Solution
- 139. Word Break - Solution
- 141. Linked List Cycle - Solution
- 142. Linked List Cycle II - Solution
- 143. Reorder List - Solution
- 144. Binary Tree Preorder Traversal - Solution
- 147. Insertion Sort List - Solution
- 148. Sort List - Solution
- 150. Evaluate Reverse Polish Notation - Solution
- 151. Reverse Words in a String - Solution
- 152. Maximum Product Subarray - Solution
- 153. Find Minimum in Rotated Sorted Array - Solution
- 162. Find Peak Element - Solution
- 173. Binary Search Tree Iterator - Solution
- 179. Largest Number - Solution
- 199. Binary Tree Right Side View - Solution
- 213. House Robber II - Solution
- 215. Kth Largest Element in an Array - Solution
- 216. Combination Sum III - Solution
- 221. Maximal Square - Solution
- 227. Basic Calculator II - Solution
- 229. Majority Element II - Solution
- 230. Kth Smallest Element in a BST - Solution
- 236. Lowest Common Ancestor of a Binary Tree - Solution
- 238. Product of Array Except Self - Solution
- 240. Search a 2D Matrix II - Solution
- 241. Different Ways to Add Parentheses - Solution
- 244. Shortest Word Distance II - Solution
- 245. Shortest Word Distance III - Solution
- 260. Single Number III - Solution
- 268. Missing Number - Solution
- 274. H-Index - Solution
- 284. Peeking Iterator - Solution
- 300. Longest Increasing Subsequence - Solution
- 309. Best Time to Buy and Sell Stock with Cooldown - Solution
- 318. Maximum Product of Word Lengths - Solution
- 319. Bulb Switcher - Solution
- 331. Verify Preorder Serialization of a Binary Tree - Solution
- 337. House Robber III - Solution
- 338. Counting Bits - Solution
- 347. Top K Frequent Elements - Solution
- 515. Find Largest Value in Each Tree Row - Solution
- 23. Merge k Sorted Lists - Solution
- 25. Reverse Nodes in k-Group - Solution
- 32. Longest Valid Parentheses - Solution
- 41. First Missing Positive - Solution
- 45. Jump Game II - Solution
- 56. Merge Intervals - Solution
- 57. Insert Interval - Solution
- 65. Valid Number - Solution
- 115. Distinct Subsequences - Solution
- 117. Populating Next Right Pointers in Each Node II - Solution
- 123. Best Time to Buy and Sell Stock III - Solution
- 132. Palindrome Partitioning II - Solution
- 145. Binary Tree Postorder Traversal - Solution
- 154. Find Minimum in Rotated Sorted Array II - Solution
- 273. Integer to English Words - Solution
- 287. Find the Duplicate Number - Solution