Skip to content

🐳 LeetCode of algorithms with JavaScript solutions written in TypeScript.

Notifications You must be signed in to change notification settings

Shyam-Chen/TypeScript-Solutions

Repository files navigation

TypeScript Solutions

🐳 LeetCode of algorithms with JavaScript solutions written in TypeScript.

Usage

  1. Clone this project
$ git clone https://github.com/Shyam-Chen/TypeScript-Solutions
$ cd TypeScript-Solutions
  1. Install dependencies
$ pnpm install
  1. Run tests
$ pnpm test

# run a specific test file
$ pnpm test <FILE_NAME>
# e.g.
$ pnpm test twoSum.test.ts

Beginning - Algorithms

解題前應該學會的思路與技巧

  1. 陣列 (Array)
  2. 鏈結串列 (Linked List)
  3. 堆疊 (Stack)
  4. 佇列 (Queue)
  5. 雜湊表 (Hash Table)
  6. 樹 (Tree)
  7. 堆積 (Heap)
  8. 圖 (Graph)
  9. 字典樹 (Trie)
  10. 排序 (Sorting)
  11. 搜尋 (Searching)
  12. 分治 (Divide and Conquer)
  13. 回溯 (Backtracking)
  14. 動態規劃 (Dynamic Programming)
  15. 貪婪 (Greedy)
  16. 位元操作 (Bit Manipulation)

Basic - LeetCode 75

Ace Coding Interview with 75 Qs

  • 75 Essential & Trending Problems
  • Must-do problem list for interview prep
  • Best for 1~3 month of prep time
Problems
Array / String
1768. Merge Strings Alternately Solution Easy
1071. Greatest Common Divisor of Strings Solution Easy
1431. Kids With the Greatest Number of Candies Solution Easy
605. Can Place Flowers Solution Easy
345. Reverse Vowels of a String Solution Easy
151. Reverse Words in a String Solution Medium
238. Product of Array Except Self Solution Medium
334. Increasing Triplet Subsequence Solution Medium
443. String Compression Solution Medium
Two Pointers
283. Move Zeroes Solution Easy
392. Is Subsequence Solution Easy
11. Container With Most Water Solution Medium
1679. Max Number of K-Sum Pairs Solution Medium
Sliding Window
643. Maximum Average Subarray I Solution Easy
1456. Maximum Number of Vowels in a Substring of Given Length Solution Medium
1004. Max Consecutive Ones III Solution Medium
1493. Longest Subarray of 1's After Deleting One Element Solution Medium
Prefix Sum
1732. Find the Highest Altitude Solution Easy
724. Find Pivot Index Solution Easy
Hash Map / Set
2215. Find the Difference of Two Arrays Solution Easy
1207. Unique Number of Occurrences Solution Easy
1657. Determine if Two Strings Are Close Solution Medium
2352. Equal Row and Column Pairs Solution Medium
Stack
2390. Removing Stars From a String Solution Medium
735. Asteroid Collision Solution Medium
394. Decode String Solution Medium
Queue
933. Number of Recent Calls Solution Easy
649. Dota2 Senate Solution Medium
Linked List
2095. Delete the Middle Node of a Linked List Solution Medium
328. Odd Even Linked List Solution Medium
206. Reverse Linked List Solution Easy
2130. Maximum Twin Sum of a Linked List Solution Medium
Binary Tree - DFS
104. Maximum Depth of Binary Tree Solution Easy
872. Leaf-Similar Trees Solution Easy
1448. Count Good Nodes in Binary Tree Solution Medium
437. Path Sum III Solution Medium
1372. Longest ZigZag Path in a Binary Tree Solution Medium
236. Lowest Common Ancestor of a Binary Tree Solution Medium
Binary Tree - BFS
199. Binary Tree Right Side View Solution Medium
1161. Maximum Level Sum of a Binary Tree Solution Medium
Binary Search Tree
700. Search in a Binary Search Tree Solution Easy
450. Delete Node in a BST Solution Medium
Graphs - DFS
841. Keys and Rooms Solution Medium
547. Number of Provinces Solution Medium
1466. Reorder Routes to Make All Paths Lead to the City Zero Solution Medium
399. Evaluate Division Solution Medium
Graphs - BFS
1926. Nearest Exit from Entrance in Maze Solution Medium
994. Rotting Oranges Solution Medium
Heap / Priority Queue
215. Kth Largest Element in an Array Solution Medium
2336. Smallest Number in Infinite Set Solution Medium
2542. Maximum Subsequence Score Solution Medium
2462. Total Cost to Hire K Workers Solution Medium
Binary Search
374. Guess Number Higher or Lower Solution Easy
2300. Successful Pairs of Spells and Potions Solution Medium
162. Find Peak Element Solution Medium
875. Koko Eating Bananas Solution Medium
Backtracking
17. Letter Combinations of a Phone Number Solution Medium
216. Combination Sum III Solution Medium
DP - 1D
1137. N-th Tribonacci Number Solution Easy
746. Min Cost Climbing Stairs Solution Easy
198. House Robber Solution Medium
790. Domino and Tromino Tiling Solution Medium
DP - Multidimensional
62. Unique Paths Solution Medium
1143. Longest Common Subsequence Solution Medium
714. Best Time to Buy and Sell Stock with Transaction Fee Solution Medium
72. Edit Distance Solution Medium
Bit Manipulation
338. Counting Bits Solution Easy
136. Single Number Solution Easy
1318. Minimum Flips to Make a OR b Equal to c Solution Medium
Trie
208. Implement Trie (Prefix Tree) Solution Medium
1268. Search Suggestions System Solution Medium
Intervals
435. Non-overlapping Intervals Solution Medium
452. Minimum Number of Arrows to Burst Balloons Solution Medium
Monotonic Stack
739. Daily Temperatures Solution Medium
901. Online Stock Span Solution Medium

Advanced - Top Interview 150

Must-do List for Interview Prep

  • 150 Original & Classic Questions
  • Covers comprehensive interview topics
  • Best for 3+ months of prep time
  • Problems support high-quality editorials
Problems
Array / String
88. Merge Sorted Array Solution Easy
27. Remove Element Solution Easy
26. Remove Duplicates from Sorted Array Solution Easy
80. Remove Duplicates from Sorted Array II Solution Medium
169. Majority Element Solution Easy
189. Rotate Array Solution Medium
121. Best Time to Buy and Sell Stock Solution Easy
122. Best Time to Buy and Sell Stock II Solution Medium
55. Jump Game Solution Medium
45. Jump Game II Solution Medium
274. H-Index Solution Medium
380. Insert Delete GetRandom O(1) Solution Medium
238. Product of Array Except Self Solution Medium
134. Gas Station Solution Medium
135. Candy Solution Hard
42. Trapping Rain Water Solution Hard
13. Roman to Integer Solution Easy
12. Integer to Roman Solution Medium
58. Length of Last Word Solution Easy
14. Longest Common Prefix Solution Easy
151. Reverse Words in a String Solution Medium
6. Zigzag Conversion Solution Medium
28. Find the Index of the First Occurrence in a String Solution Easy
68. Text Justification Solution Hard
Two Pointers
125. Valid Palindrome Solution Easy
392. Is Subsequence Solution Easy
167. Two Sum II - Input Array Is Sorted Solution Medium
11. Container With Most Water Solution Medium
15. 3Sum Solution Medium
Sliding Window
209. Minimum Size Subarray Sum Solution Medium
3. Longest Substring Without Repeating Characters Solution Medium
30. Substring with Concatenation of All Words Solution Hard
76. Minimum Window Substring Solution Hard
Matrix
36. Valid Sudoku Solution Medium
54. Spiral Matrix Solution Medium
48. Rotate Image Solution Medium
73. Set Matrix Zeroes Solution Medium
289. Game of Life Solution Medium
Hashmap
383. Ransom Note Solution Easy
205. Isomorphic Strings Solution Easy
290. Word Pattern Solution Easy
242. Valid Anagram Solution Easy
49. Group Anagrams Solution Medium
1. Two Sum Solution Easy
202. Happy Number Solution Easy
219. Contains Duplicate II Solution Easy
128. Longest Consecutive Sequence Solution Medium
Intervals
228. Summary Ranges Solution Easy
56. Merge Intervals Solution Medium
57. Insert Interval Solution Medium
452. Minimum Number of Arrows to Burst Balloons Solution Medium
Stack
20. Valid Parentheses Solution Easy
71. Simplify Path Solution Medium
155. Min Stack Solution Medium
150. Evaluate Reverse Polish Notation Solution Medium
224. Basic Calculator Solution Hard
Linked List
141. Linked List Cycle Solution Easy
2. Add Two Numbers Solution Medium
21. Merge Two Sorted Lists Solution Easy
138. Copy List with Random Pointer Solution Medium
92. Reverse Linked List II Solution Medium
25. Reverse Nodes in k-Group Solution Hard
19. Remove Nth Node From End of List Solution Medium
82. Remove Duplicates from Sorted List II Solution Medium
61. Rotate List Solution Medium
86. Partition List Solution Medium
146. LRU Cache Solution Medium
Binary Tree General
104. Maximum Depth of Binary Tree Solution Easy
100. Same Tree Solution Easy
226. Invert Binary Tree Solution Easy
101. Symmetric Tree Solution Easy
105. Construct Binary Tree from Preorder and Inorder Traversal Solution Medium
106. Construct Binary Tree from Inorder and Postorder Traversal Solution Medium
117. Populating Next Right Pointers in Each Node II Solution Medium
114. Flatten Binary Tree to Linked List Solution Medium
112. Path Sum Solution Easy
129. Sum Root to Leaf Numbers Solution Medium
124. Binary Tree Maximum Path Sum Solution Hard
173. Binary Search Tree Iterator Solution Medium
222. Count Complete Tree Nodes Solution Easy
236. Lowest Common Ancestor of a Binary Tree Solution Medium
Binary Tree BFS
199. Binary Tree Right Side View Solution Medium
637. Average of Levels in Binary Tree Solution Easy
102. Binary Tree Level Order Traversal Solution Medium
103. Binary Tree Zigzag Level Order Traversal Solution Medium
Binary Search Tree
530. Minimum Absolute Difference in BST Solution Easy
230. Kth Smallest Element in a BST Solution Medium
98. Validate Binary Search Tree Solution Medium
Graph General
200. Number of Islands Solution Medium
130. Surrounded Regions Solution Medium
133. Clone Graph Solution Medium
399. Evaluate Division Solution Medium
207. Course Schedule Solution Medium
210. Course Schedule II Solution Medium
Graph BFS
909. Snakes and Ladders Solution Medium
433. Minimum Genetic Mutation Solution Medium
127. Word Ladder Solution Hard
Trie
208. Implement Trie (Prefix Tree) Solution Medium
211. Design Add and Search Words Data Structure Solution Medium
212. Word Search II Solution Hard
Backtracking
17. Letter Combinations of a Phone Number Solution Medium
77. Combinations Solution Medium
46. Permutations Solution Medium
39. Combination Sum Solution Medium
52. N-Queens II Solution Hard
22. Generate Parentheses Solution Medium
79. Word Search Solution Medium
Divide & Conquer
108. Convert Sorted Array to Binary Search Tree Solution Easy
148. Sort List Solution Medium
427. Construct Quad Tree Solution Medium
23. Merge k Sorted Lists Solution Hard
Kadane's Algorithm
53. Maximum Subarray Solution Medium
918. Maximum Sum Circular Subarray Solution Medium
Binary Search
35. Search Insert Position Solution Easy
74. Search a 2D Matrix Solution Medium
162. Find Peak Element Solution Medium
33. Search in Rotated Sorted Array Solution Medium
34. Find First and Last Position of Element in Sorted Array Solution Medium
153. Find Minimum in Rotated Sorted Array Solution Medium
4. Median of Two Sorted Arrays Solution Hard
Heap
215. Kth Largest Element in an Array Solution Medium
502. IPO Solution Hard
373. Find K Pairs with Smallest Sums Solution Medium
295. Find Median from Data Stream Solution Hard
Bit Manipulation
67. Add Binary Solution Easy
190. Reverse Bits Solution Easy
191. Number of 1 Bits Solution Easy
136. Single Number Solution Easy
137. Single Number II Solution Medium
201. Bitwise AND of Numbers Range Solution Medium
Math
9. Palindrome Number Solution Easy
66. Plus One Solution Easy
172. Factorial Trailing Zeroes Solution Medium
69. Sqrt(x) Solution Easy
50. Pow(x, n) Solution Medium
149. Max Points on a Line Solution Hard
1D DP
70. Climbing Stairs Solution Easy
198. House Robber Solution Medium
139. Word Break Solution Medium
322. Coin Change Solution Medium
300. Longest Increasing Subsequence Solution Medium
Multidimensional DP
120. Triangle Solution Medium
64. Minimum Path Sum Solution Medium
63. Unique Paths II Solution Medium
5. Longest Palindromic Substring Solution Medium
97. Interleaving String Solution Medium
72. Edit Distance Solution Medium
123. Best Time to Buy and Sell Stock III Solution Hard
188. Best Time to Buy and Sell Stock IV Solution Hard
221. Maximal Square Solution Medium

Impactful - Top 100 Liked

100 Best Rated Problems

  • 100 most liked problems by LeetCoders
  • Organized based on hot topics that help improve coding skills in interviews
Problems
Backtracking
17. Letter Combinations of a Phone Number Solution Medium
22. Generate Parentheses Solution Medium
39. Combination Sum Solution Medium
46. Permutations Solution Medium
51. N-Queens Solution Hard
78. Subsets Solution Medium
79. Word Search Solution Medium
131. Palindrome Partitioning Solution Medium
Binary Search
4. Median of Two Sorted Arrays Solution Hard
33. Search in Rotated Sorted Array Solution Medium
34. Find First and Last Position of Element in Sorted Array Solution Medium
35. Search Insert Position Solution Easy
74. Search a 2D Matrix Solution Medium
124. Binary Tree Maximum Path Sum Solution Hard
153. Find Minimum in Rotated Sorted Array Solution Medium
Binary Tree
94. Binary Tree Inorder Traversal Solution Easy
98. Validate Binary Search Tree Solution Medium
101. Symmetric Tree Solution Easy
102. Binary Tree Level Order Traversal Solution Medium
104. Maximum Depth of Binary Tree Solution Easy
105. Construct Binary Tree from Preorder and Inorder Traversal Solution Medium
108. Convert Sorted Array to Binary Search Tree Solution Easy
114. Flatten Binary Tree to Linked List Solution Medium
199. Binary Tree Right Side View Solution Medium
226. Invert Binary Tree Solution Easy
230. Kth Smallest Element in a BST Solution Medium
236. Lowest Common Ancestor of a Binary Tree Solution Medium
437. Path Sum III Solution Medium
543. Diameter of Binary Tree Solution Easy
Dynamic Programming
5. Longest Palindromic Substring Solution Medium
32. Longest Valid Parentheses Solution Hard
62. Unique Paths Solution Medium
64. Minimum Path Sum Solution Medium
70. Climbing Stairs Solution Easy
72. Edit Distance Solution Medium
118. Pascal's Triangle Solution Easy
139. Word Break Solution Medium
152. Maximum Product Subarray Solution Medium
198. House Robber Solution Medium
279. Perfect Squares Solution Medium
300. Longest Increasing Subsequence Solution Medium
322. Coin Change Solution Medium
416. Partition Equal Subset Sum Solution Medium
1143. Longest Common Subsequence Solution Medium
Graph
200. Number of Islands Solution Medium
207. Course Schedule Solution Medium
994. Rotting Oranges Solution Medium
Greedy
45. Jump Game II Solution Medium
55. Jump Game Solution Medium
121. Best Time to Buy and Sell Stock Solution Easy
763. Partition Labels Solution Medium
Hashing
1. Two Sum Solution Easy
49. Group Anagrams Solution Medium
128. Longest Consecutive Sequence Solution Medium
560. Subarray Sum Equals K Solution Medium
Heap
215. Kth Largest Element in an Array Solution Medium
295. Find Median from Data Stream Solution Hard
347. Top K Frequent Elements Solution Medium
Linked Lists
2. Add Two Numbers Solution Medium
19. Remove Nth Node From End of List Solution Medium
21. Merge Two Sorted Lists Solution Easy
23. Merge k Sorted Lists Solution Hard
24. Swap Nodes in Pairs Solution Medium
25. Reverse Nodes in k-Group Solution Hard
138. Copy List with Random Pointer Solution Medium
141. Linked List Cycle Solution Easy
142. Linked List Cycle II Solution Medium
146. LRU Cache Solution Medium
148. Sort List Solution Medium
160. Intersection of Two Linked Lists Solution Easy
206. Reverse Linked List Solution Easy
234. Palindrome Linked List Solution Easy
Matrix
48. Rotate Image Solution Medium
54. Spiral Matrix Solution Medium
73. Set Matrix Zeroes Solution Medium
240. Search a 2D Matrix II Solution Medium
Sliding Window
3. Longest Substring Without Repeating Characters Solution Medium
76. Minimum Window Substring Solution Hard
239. Sliding Window Maximum Solution Hard
438. Find All Anagrams in a String Solution Medium
Stack
20. Valid Parentheses Solution Easy
84. Largest Rectangle in Histogram Solution Hard
155. Min Stack Solution Medium
394. Decode String Solution Medium
739. Daily Temperatures Solution Medium
Two Pointers
11. Container With Most Water Solution Medium
15. 3Sum Solution Medium
42. Trapping Rain Water Solution Hard
283. Move Zeroes Solution Easy
Trie
208. Implement Trie (Prefix Tree) Solution Medium
Misc
31. Next Permutation Solution Medium
41. First Missing Positive Solution Hard
53. Maximum Subarray Solution Medium
56. Merge Intervals Solution Medium
75. Sort Colors Solution Medium
136. Single Number Solution Easy
169. Majority Element Solution Easy
189. Rotate Array Solution Medium
238. Product of Array Except Self Solution Medium
287. Find the Duplicate Number Solution Medium

About

🐳 LeetCode of algorithms with JavaScript solutions written in TypeScript.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages