iplus26 / LeetCode-Solutions

My LeetCode Solutions, mostly in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Your Own Version

I write a tool (check out the build/ folder) to optimize the process. It will programmatically:

  1. Fetch the problem list from LeetCode OJ and save in build/leetcode.html

  2. Check out the local solutions (Pls save the code as 123. Some Problem/whatever-you-like.js)

  3. Update the README file

Try it: Just clone the repo and run

npm install && npm run build

Be free to contact to discuss about this simple tool.

My Version

This is my version of LeetCode solutions.

90 / 382 questions solved. (πŸ˜„ for Easy, 😎 for Medium, 😈 for Hard)

# Difficulty Title C C++ Java JavaScript
1 πŸ˜„ Two Sum ⭐️
2 😎 Add Two Numbers ⭐️
3 😎 Longest Substring Without Repeating Characters ⭐️
4 😈 Median of Two Sorted Arrays
5 😎 Longest Palindromic Substring
6 πŸ˜„ ZigZag Conversion ⭐️
7 πŸ˜„ Reverse Integer ⭐️ ⭐️
8 πŸ˜„ String to Integer (atoi) ⭐️
9 πŸ˜„ Palindrome Number ⭐️
10 😈 Regular Expression Matching
11 😎 Container With Most Water
12 😎 Integer to Roman ⭐️
13 πŸ˜„ Roman to Integer ⭐️
14 πŸ˜„ Longest Common Prefix ⭐️
15 😎 3Sum ⭐️
16 😎 3Sum Closest
17 😎 Letter Combinations of a Phone Number
18 😎 4Sum
19 πŸ˜„ Remove Nth Node From End of List ⭐️
20 πŸ˜„ Valid Parentheses ⭐️
21 πŸ˜„ Merge Two Sorted Lists ⭐️
22 😎 Generate Parentheses ⭐️
23 😈 Merge k Sorted Lists
24 πŸ˜„ Swap Nodes in Pairs ⭐️
25 😈 Reverse Nodes in k-Group
26 πŸ˜„ Remove Duplicates from Sorted Array ⭐️
27 πŸ˜„ Remove Element ⭐️
28 πŸ˜„ Implement strStr() ⭐️ ⭐️
29 😎 Divide Two Integers
30 😈 Substring with Concatenation of All Words
31 😎 Next Permutation
32 😈 Longest Valid Parentheses
33 😈 Search in Rotated Sorted Array
34 😎 Search for a Range ⭐️
35 😎 Search Insert Position
36 πŸ˜„ Valid Sudoku
37 😈 Sudoku Solver
38 πŸ˜„ Count and Say ⭐️
39 😎 Combination Sum
40 😎 Combination Sum II
41 😈 First Missing Positive ⭐️
42 😈 Trapping Rain Water
43 😎 Multiply Strings
44 😈 Wildcard Matching
45 😈 Jump Game II
46 😎 Permutations
47 😎 Permutations II
48 😎 Rotate Image
49 😎 Group Anagrams
50 😎 Pow(x, n) ⭐️
51 😈 N-Queens
52 😈 N-Queens II
53 😎 Maximum Subarray
54 😎 Spiral Matrix ⭐️
55 😎 Jump Game
56 😈 Merge Intervals
57 😈 Insert Interval
58 πŸ˜„ Length of Last Word ⭐️
59 😎 Spiral Matrix II
60 😎 Permutation Sequence
61 😎 Rotate List
62 😎 Unique Paths
63 😎 Unique Paths II
64 😎 Minimum Path Sum
65 😈 Valid Number
66 πŸ˜„ Plus One ⭐️
67 πŸ˜„ Add Binary ⭐️
68 😈 Text Justification
69 😎 Sqrt(x) ⭐️
70 πŸ˜„ Climbing Stairs ⭐️
71 😎 Simplify Path ⭐️
72 😈 Edit Distance
73 😎 Set Matrix Zeroes
74 😎 Search a 2D Matrix
75 😎 Sort Colors
76 😈 Minimum Window Substring
77 😎 Combinations
78 😎 Subsets
79 😎 Word Search
80 😎 Remove Duplicates from Sorted Array II
81 😎 Search in Rotated Sorted Array II
82 😎 Remove Duplicates from Sorted List II
83 πŸ˜„ Remove Duplicates from Sorted List ⭐️
84 😈 Largest Rectangle in Histogram
85 😈 Maximal Rectangle
86 😎 Partition List
87 😈 Scramble String
88 πŸ˜„ Merge Sorted Array ⭐️
89 😎 Gray Code
90 😎 Subsets II
91 😎 Decode Ways
92 😎 Reverse Linked List II
93 😎 Restore IP Addresses
94 😎 Binary Tree Inorder Traversal ⭐️
95 😎 Unique Binary Search Trees II
96 😎 Unique Binary Search Trees
97 😈 Interleaving String
98 😎 Validate Binary Search Tree
99 😈 Recover Binary Search Tree
100 πŸ˜„ Same Tree
101 πŸ˜„ Symmetric Tree
102 πŸ˜„ Binary Tree Level Order Traversal
103 😎 Binary Tree Zigzag Level Order Traversal
104 πŸ˜„ Maximum Depth of Binary Tree
105 😎 Construct Binary Tree from Preorder and Inorder Traversal
106 😎 Construct Binary Tree from Inorder and Postorder Traversal
107 πŸ˜„ Binary Tree Level Order Traversal II
108 😎 Convert Sorted Array to Binary Search Tree
109 😎 Convert Sorted List to Binary Search Tree
110 πŸ˜„ Balanced Binary Tree
111 πŸ˜„ Minimum Depth of Binary Tree
112 πŸ˜„ Path Sum
113 😎 Path Sum II ⭐️
114 😎 Flatten Binary Tree to Linked List ⭐️
115 😈 Distinct Subsequences
116 😎 Populating Next Right Pointers in Each Node
117 😈 Populating Next Right Pointers in Each Node II
118 πŸ˜„ Pascal's Triangle
119 πŸ˜„ Pascal's Triangle II
120 😎 Triangle
121 πŸ˜„ Best Time to Buy and Sell Stock
122 😎 Best Time to Buy and Sell Stock II
123 😈 Best Time to Buy and Sell Stock III
124 😈 Binary Tree Maximum Path Sum
125 πŸ˜„ Valid Palindrome
126 😈 Word Ladder II
127 😎 Word Ladder
128 😈 Longest Consecutive Sequence
129 😎 Sum Root to Leaf Numbers ⭐️
130 😎 Surrounded Regions
131 😎 Palindrome Partitioning
132 😈 Palindrome Partitioning II
133 😎 Clone Graph
134 😎 Gas Station
135 😈 Candy
136 πŸ˜„ Single Number ⭐️
137 😎 Single Number II
138 😈 Copy List with Random Pointer
139 😎 Word Break
140 😈 Word Break II
141 πŸ˜„ Linked List Cycle ⭐️
142 😎 Linked List Cycle II
143 😎 Reorder List
144 😎 Binary Tree Preorder Traversal ⭐️
145 😈 Binary Tree Postorder Traversal ⭐️
146 😈 LRU Cache
147 😎 Insertion Sort List
148 😎 Sort List
149 😈 Max Points on a Line
150 😎 Evaluate Reverse Polish Notation
151 😎 Reverse Words in a String
152 😎 Maximum Product Subarray
153 😎 Find Minimum in Rotated Sorted Array ⭐️
154 😈 Find Minimum in Rotated Sorted Array II
155 πŸ˜„ Min Stack ⭐️
156 😎 πŸ”’Binary Tree Upside Down
157 πŸ˜„ πŸ”’Read N Characters Given Read4
158 😈 πŸ”’Read N Characters Given Read4 II - Call multiple times
159 😈 πŸ”’Longest Substring with At Most Two Distinct Characters
160 πŸ˜„ Intersection of Two Linked Lists ⭐️
161 😎 πŸ”’One Edit Distance
162 😎 Find Peak Element
163 😎 πŸ”’Missing Ranges
164 😈 Maximum Gap
165 πŸ˜„ Compare Version Numbers ⭐️
166 😎 Fraction to Recurring Decimal
167 😎 Two Sum II - Input array is sorted
168 πŸ˜„ Excel Sheet Column Title ⭐️ ⭐️
169 πŸ˜„ Majority Element
170 πŸ˜„ πŸ”’Two Sum III - Data structure design
171 πŸ˜„ Excel Sheet Column Number ⭐️ ⭐️
172 πŸ˜„ Factorial Trailing Zeroes ⭐️
173 😎 Binary Search Tree Iterator
174 😈 Dungeon Game
179 😎 Largest Number ⭐️
186 😎 πŸ”’Reverse Words in a String II
187 😎 Repeated DNA Sequences
188 😈 Best Time to Buy and Sell Stock IV
189 πŸ˜„ Rotate Array ⭐️
190 πŸ˜„ Reverse Bits ⭐️
191 πŸ˜„ Number of 1 Bits ⭐️
198 πŸ˜„ House Robber ⭐️
199 😎 Binary Tree Right Side View ⭐️
200 😎 Number of Islands ⭐️
201 😎 Bitwise AND of Numbers Range
202 πŸ˜„ Happy Number ⭐️
203 πŸ˜„ Remove Linked List Elements ⭐️
204 πŸ˜„ Count Primes ⭐️
205 πŸ˜„ Isomorphic Strings ⭐️
206 πŸ˜„ Reverse Linked List ⭐️
207 😎 Course Schedule
208 😎 Implement Trie (Prefix Tree)
209 😎 Minimum Size Subarray Sum
210 😎 Course Schedule II
211 😎 Add and Search Word - Data structure design
212 😈 Word Search II
213 😎 House Robber II
214 😈 Shortest Palindrome
215 😎 Kth Largest Element in an Array
216 😎 Combination Sum III
217 πŸ˜„ Contains Duplicate ⭐️
218 😈 The Skyline Problem
219 πŸ˜„ Contains Duplicate II ⭐️
220 😎 Contains Duplicate III
221 😎 Maximal Square
222 😎 Count Complete Tree Nodes ⭐️
223 πŸ˜„ Rectangle Area ⭐️
224 😈 Basic Calculator
225 πŸ˜„ Implement Stack using Queues ⭐️
226 πŸ˜„ Invert Binary Tree ⭐️
227 😎 Basic Calculator II
228 😎 Summary Ranges
229 😎 Majority Element II ⭐️
230 😎 Kth Smallest Element in a BST ⭐️
231 πŸ˜„ Power of Two ⭐️
232 πŸ˜„ Implement Queue using Stacks ⭐️
233 😈 Number of Digit One ⭐️
234 πŸ˜„ Palindrome Linked List ⭐️
235 πŸ˜„ Lowest Common Ancestor of a Binary Search Tree ⭐️
236 😎 Lowest Common Ancestor of a Binary Tree
237 πŸ˜„ Delete Node in a Linked List ⭐️
238 😎 Product of Array Except Self ⭐️
239 😈 Sliding Window Maximum
240 😎 Search a 2D Matrix II
241 😎 Different Ways to Add Parentheses
242 πŸ˜„ Valid Anagram ⭐️
243 πŸ˜„ πŸ”’Shortest Word Distance
244 😎 πŸ”’Shortest Word Distance II
245 😎 πŸ”’Shortest Word Distance III
246 πŸ˜„ πŸ”’Strobogrammatic Number
247 😎 πŸ”’Strobogrammatic Number II
248 😈 πŸ”’Strobogrammatic Number III
249 πŸ˜„ πŸ”’Group Shifted Strings
250 😎 πŸ”’Count Univalue Subtrees
251 😎 πŸ”’Flatten 2D Vector
252 πŸ˜„ πŸ”’Meeting Rooms
253 😎 πŸ”’Meeting Rooms II
254 😎 πŸ”’Factor Combinations
255 😎 πŸ”’Verify Preorder Sequence in Binary Search Tree
256 😎 πŸ”’Paint House
257 πŸ˜„ Binary Tree Paths ⭐️
258 πŸ˜„ Add Digits ⭐️
259 😎 πŸ”’3Sum Smaller
260 😎 Single Number III
261 😎 πŸ”’Graph Valid Tree
263 πŸ˜„ Ugly Number ⭐️
264 😎 Ugly Number II
265 😈 πŸ”’Paint House II
266 πŸ˜„ πŸ”’Palindrome Permutation
267 😎 πŸ”’Palindrome Permutation II
268 😎 Missing Number ⭐️
269 😈 πŸ”’Alien Dictionary
270 πŸ˜„ πŸ”’Closest Binary Search Tree Value
271 😎 πŸ”’Encode and Decode Strings
272 😈 πŸ”’Closest Binary Search Tree Value II
273 😈 Integer to English Words
274 😎 H-Index
275 😎 H-Index II
276 πŸ˜„ πŸ”’Paint Fence
277 😎 πŸ”’Find the Celebrity
278 πŸ˜„ First Bad Version ⭐️
279 😎 Perfect Squares
280 😎 πŸ”’Wiggle Sort
281 😎 πŸ”’Zigzag Iterator
282 😈 Expression Add Operators
283 πŸ˜„ Move Zeroes ⭐️
284 😎 Peeking Iterator
285 😎 πŸ”’Inorder Successor in BST
286 😎 πŸ”’Walls and Gates
287 😈 Find the Duplicate Number
288 πŸ˜„ πŸ”’Unique Word Abbreviation
289 😎 Game of Life
290 πŸ˜„ Word Pattern
291 😈 πŸ”’Word Pattern II
292 πŸ˜„ Nim Game
293 πŸ˜„ πŸ”’Flip Game
294 😎 πŸ”’Flip Game II
295 😈 Find Median from Data Stream
296 😈 πŸ”’Best Meeting Point
297 😈 Serialize and Deserialize Binary Tree
298 😎 πŸ”’Binary Tree Longest Consecutive Sequence
299 πŸ˜„ Bulls and Cows
300 😎 Longest Increasing Subsequence
301 😈 Remove Invalid Parentheses
302 😈 πŸ”’Smallest Rectangle Enclosing Black Pixels
303 πŸ˜„ Range Sum Query - Immutable ⭐️
304 😎 Range Sum Query 2D - Immutable
305 😈 πŸ”’Number of Islands II
306 😎 Additive Number
307 😎 Range Sum Query - Mutable
308 😈 πŸ”’Range Sum Query 2D - Mutable
309 😎 Best Time to Buy and Sell Stock with Cooldown
310 😎 Minimum Height Trees
311 😎 πŸ”’Sparse Matrix Multiplication
312 😈 Burst Balloons
313 😎 Super Ugly Number
314 😎 πŸ”’Binary Tree Vertical Order Traversal
315 😈 Count of Smaller Numbers After Self
316 😈 Remove Duplicate Letters
317 😈 πŸ”’Shortest Distance from All Buildings
318 😎 Maximum Product of Word Lengths
319 😎 Bulb Switcher
320 😎 πŸ”’Generalized Abbreviation
321 😈 Create Maximum Number
322 😎 Coin Change
323 😎 πŸ”’Number of Connected Components in an Undirected Graph
324 😎 Wiggle Sort II
325 😎 πŸ”’Maximum Size Subarray Sum Equals k
326 πŸ˜„ Power of Three ⭐️
327 😈 Count of Range Sum
328 😎 Odd Even Linked List ⭐️
329 😈 Longest Increasing Path in a Matrix
330 😈 Patching Array
331 😎 Verify Preorder Serialization of a Binary Tree ⭐️
332 😎 Reconstruct Itinerary
333 😎 πŸ”’Largest BST Subtree
334 😎 Increasing Triplet Subsequence
335 😈 Self Crossing
336 😈 Palindrome Pairs
337 😎 House Robber III
338 😎 Counting Bits
339 πŸ˜„ πŸ”’Nested List Weight Sum
340 😈 πŸ”’Longest Substring with At Most K Distinct Characters
341 😎 Flatten Nested List Iterator
342 πŸ˜„ Power of Four ⭐️
343 😎 Integer Break
344 πŸ˜„ Reverse String ⭐️
345 πŸ˜„ Reverse Vowels of a String ⭐️
346 πŸ˜„ πŸ”’Moving Average from Data Stream
347 😎 Top K Frequent Elements
348 😎 πŸ”’Design Tic-Tac-Toe
349 πŸ˜„ Intersection of Two Arrays ⭐️
350 πŸ˜„ Intersection of Two Arrays II ⭐️
351 😎 πŸ”’Android Unlock Patterns
352 😈 Data Stream as Disjoint Intervals
353 😎 πŸ”’Design Snake Game
354 😈 Russian Doll Envelopes
355 😎 Design Twitter
356 😎 πŸ”’Line Reflection
357 😎 Count Numbers with Unique Digits
358 😈 πŸ”’Rearrange String k Distance Apart
359 πŸ˜„ πŸ”’Logger Rate Limiter
360 😎 πŸ”’Sort Transformed Array
361 😎 πŸ”’Bomb Enemy
362 😎 πŸ”’Design Hit Counter
363 😈 Max Sum of Rectangle No Larger Than K
364 😎 πŸ”’Nested List Weight Sum II
365 😎 Water and Jug Problem
366 😎 πŸ”’Find Leaves of Binary Tree
367 😎 Valid Perfect Square
368 😎 Largest Divisible Subset
369 😎 πŸ”’Plus One Linked List
370 😎 πŸ”’Range Addition
371 πŸ˜„ Sum of Two Integers
372 😎 Super Pow
373 😎 Find K Pairs with Smallest Sums
374 πŸ˜„ Guess Number Higher or Lower
375 😎 Guess Number Higher or Lower II
376 😎 Wiggle Subsequence
377 😎 Combination Sum IV
378 😎 Kth Smallest Element in a Sorted Matrix
379 😎 πŸ”’Design Phone Directory
380 😈 Insert Delete GetRandom O(1)
381 😈 Insert Delete GetRandom O(1) - Duplicates allowed
382 😎 Linked List Random Node
383 πŸ˜„ Ransom Note
384 😎 Shuffle an Array
385 😎 Mini Parser
386 😎 Lexicographical Numbers
387 πŸ˜„ First Unique Character in a String
388 😎 Longest Absolute File Path
389 πŸ˜„ Find the Difference
390 😎 Elimination Game
391 😈 Perfect Rectangle
392 😎 Is Subsequence
393 😎 UTF-8 Validation
394 😎 Decode String
395 😎 Longest Substring with At Least K Repeating Characters
396 πŸ˜„ Rotate Function
397 πŸ˜„ Integer Replacement
398 😎 Random Pick Index
399 😎 Evaluate Division

About

My LeetCode Solutions, mostly in JavaScript


Languages

Language:JavaScript 75.2%Language:C 20.4%Language:C++ 2.4%Language:Java 2.0%