这是一份关于leetcode上的javascript解决方案的分析

by Vitrum @ 2018

编程10多年,积累了成吨的工具和代码片段库,可是随着javascript的大热,越来越多新知识新工具新想法不断在冲击,常常面临种种选择,这时候,会想问问自己,人生究竟应该积累些什么?

也许是时候回过头,重拾初心。

“编程的乐趣在于 折腾算法” --鲁迅(我并没有说)


在线阅读

Github地址


关于算法

javascript-algorithms 是近期很火的项目,系统的介绍了经典算法在javascript中的应用和实现。

关于LeetCode

LeetCode是一个在线能力评测系统(英语:Online Judge,缩写OJ)提供程序员在面试时经常遇到的现场coding题目,这类算法题目的思考方式是可以通过练习来熟悉理解的,在练习的同时,页能增强自己的coding能力。LeetCode除了将这些题目搬到网上让程序员们可以选择不同开发语言进行线上coding之外,还有讨论区分享了解其他人的解题思路,并且对成功通过的代码进行PK,提供运算效率排名,并可以查看最高排名的代码。

LeetCode题目分:Easy,Medium,Hard三个难度,并且附有通过率,通常来说,相同难度里,通过率高的比较简单,建议大家由简入繁。从Easy入手,熟悉解题方法和常用算法

Problems list

# Title Solution Acceptance Difficulty
1 Two Sum Solution 38.60% Easy
2 Add Two Numbers Solution 29.00% Medium
7 Reverse Integer Solution 24.40% Easy
9 Palindrome Number Solution 37.40% Easy
13 Roman to Integer 48.90% Easy
14 Longest Common Prefix Solution 31.80% Easy
223 Rectangle Area 34.30% Medium
242 Valid Anagram Solution 48.30% Easy
771 Jewels and Stones Solution 81.90% Easy
3 [Longest Substring Without Repeating Characters] Solution 24.90% Medium
4 [Median of Two Sorted Arrays] Solution 23.50% Hard
5 [Longest Palindromic Substring] Solution 25.60% Medium
6 [ZigZag Conversion] Solution 28.10% Medium
8 [String to Integer (atoi)] Solution 14.10% Medium
10 [Regular Expression Matching] Solution 24.40% Hard
11 Container With Most Water Solution 37.50% Medium
12 Integer to Roman Solution 47.00% Medium
15 3Sum Solution 21.90% Medium
16 3Sum Closest Solution 32.20% Medium
17 Letter Combinations of a Phone Number Solution 37.50% Medium
18 4Sum Solution 28.00% Medium
19 Remove Nth Node From End of List Solution 33.80% Medium
20 Valid Parentheses Solution 34.30% Easy
21 Merge Two Sorted Lists Solution 42.40% Easy
22 Generate Parentheses Solution 49.30% Medium
23 Merge k Sorted Lists Solution 29.40% Hard
24 Swap Nodes in Pairs Solution 40.20% Medium
25 Reverse Nodes in k-Group Solution 32.60% Hard
26 Remove Duplicates from Sorted Array Solution 37.30% Easy
27 Remove Element Solution 41.50% Easy
28 Implement strStr() Solution 29.60% Easy
29 Divide Two Integers Solution 15.70% Medium
30 Substring with Concatenation of All Words Solution 22.30% Hard
31 Next Permutation Solution 29.20% Medium
32 Longest Valid Parentheses Solution 23.50% Hard
33 Search in Rotated Sorted Array Solution 32.00% Medium
34 Find First and Last Position of Element in Sorted Array Solution 31.80% Medium
35 Search Insert Position Solution 40.00% Easy
36 Valid Sudoku Solution 38.70% Medium
37 Sudoku Solver Solution 33.00% Hard
38 Count and Say Solution 37.40% Easy
39 Combination Sum Solution 42.70% Medium
40 Combination Sum II Solution 37.10% Medium
41 First Missing Positive Solution 26.40% Hard
42 Trapping Rain Water Solution 38.50% Hard
43 Multiply Strings Solution 28.40% Medium
44 Wildcard Matching Solution 21.40% Hard
45 Jump Game II Solution 26.20% Hard
46 Permutations Solution 48.90% Medium
47 Permutations II Solution 36.10% Medium
48 Rotate Image Solution 43.20% Medium
49 Group Anagrams Solution 40.20% Medium
50 "Pow(x, n) " Solution 26.40% Medium
51 N-Queens Solution 34.40% Hard
52 N-Queens II Solution 47.90% Hard
53 Maximum Subarray Solution 40.80% Easy
54 Spiral Matrix Solution 27.80% Medium
55 Jump Game Solution 30.00% Medium
56 Merge Intervals Solution 32.60% Medium
57 Insert Interval Solution 29.40% Hard
58 Length of Last Word Solution 32.10% Easy
59 Spiral Matrix II Solution 42.20% Medium
60 Permutation Sequence Solution 30.20% Medium
61 Rotate List Solution 25.00% Medium
62 Unique Paths Solution 43.80% Medium
63 Unique Paths II Solution 32.40% Medium
64 Minimum Path Sum Solution 42.10% Medium
65 Valid Number Solution 13.00% Hard
66 Plus One Solution 39.90% Easy
67 Add Binary Solution 35.10% Easy
68 Text Justification Solution 20.60% Hard
69 Sqrt(x) Solution 29.30% Easy
70 Climbing Stairs Solution 41.70% Easy
71 Simplify Path Solution 26.70% Medium
72 Edit Distance Solution 33.50% Hard
73 Set Matrix Zeroes Solution 37.20% Medium
74 Search a 2D Matrix Solution 34.50% Medium
75 Sort Colors Solution 39.60% Medium
76 Minimum Window Substring Solution 27.60% Hard
77 Combinations Solution 42.60% Medium
78 Subsets Solution 46.60% Medium
79 Word Search Solution 28.60% Medium
80 Remove Duplicates from Sorted Array II Solution 37.70% Medium
81 Search in Rotated Sorted Array II Solution 32.50% Medium
82 Remove Duplicates from Sorted List II Solution 30.60% Medium
83 Remove Duplicates from Sorted List Solution 40.60% Easy
84 Largest Rectangle in Histogram Solution 28.20% Hard
85 Maximal Rectangle Solution 30.30% Hard
86 Partition List Solution 34.30% Medium
87 Scramble String Solution 30.10% Hard
88 Merge Sorted Array Solution 32.80% Easy
89 Gray Code Solution 43.20% Medium
90 Subsets II Solution 39.20% Medium
91 Decode Ways Solution 20.70% Medium
92 Reverse Linked List II Solution 32.00% Medium
93 Restore IP Addresses Solution 29.00% Medium
94 Binary Tree Inorder Traversal Solution 51.30% Medium
95 Unique Binary Search Trees II Solution 32.90% Medium
96 Unique Binary Search Trees Solution 42.70% Medium
97 Interleaving String Solution 25.70% Hard
98 Validate Binary Search Tree Solution 24.30% Medium
99 Recover Binary Search Tree Solution 31.70% Hard
100 Same Tree Solution 48.20% Easy
101 Symmetric Tree Solution 41.00% Easy
102 Binary Tree Level Order Traversal Solution 43.90% Medium
103 Binary Tree Zigzag Level Order Traversal Solution 37.80% Medium
104 Maximum Depth of Binary Tree Solution 56.20% Easy
105 Construct Binary Tree from Preorder and Inorder Traversal Solution 35.60% Medium
106 Construct Binary Tree from Inorder and Postorder Traversal Solution 34.90% Medium
107 Binary Tree Level Order Traversal II Solution 43.20% Easy
108 Convert Sorted Array to Binary Search Tree Solution 45.70% Easy
109 Convert Sorted List to Binary Search Tree Solution 36.60% Medium
110 Balanced Binary Tree Solution 38.90% Easy
111 Minimum Depth of Binary Tree Solution 33.90% Easy
112 Path Sum Solution 35.50% Easy
113 Path Sum II Solution 36.80% Medium
114 Flatten Binary Tree to Linked List Solution 37.70% Medium
115 Distinct Subsequences Solution 32.70% Hard
116 Populating Next Right Pointers in Each Node Solution 36.70% Medium
117 Populating Next Right Pointers in Each Node II Solution 33.70% Medium
118 Pascal's Triangle Solution 41.30% Easy
119 Pascal's Triangle II Solution 39.30% Easy
120 Triangle Solution 35.80% Medium
121 Best Time to Buy and Sell Stock Solution 43.80% Easy
122 Best Time to Buy and Sell Stock II Solution 48.60% Easy
123 Best Time to Buy and Sell Stock III Solution 31.00% Hard
124 Binary Tree Maximum Path Sum Solution 27.60% Hard
125 Valid Palindrome Solution 27.90% Easy
126 Word Ladder II Solution 15.30% Hard
127 Word Ladder Solution 20.70% Medium
128 Longest Consecutive Sequence Solution 38.90% Hard
129 Sum Root to Leaf Numbers Solution 38.80% Medium
130 Surrounded Regions Solution 20.30% Medium
131 Palindrome Partitioning Solution 36.70% Medium
132 Palindrome Partitioning II Solution 25.30% Hard
133 Clone Graph Solution 25.10% Medium
134 Gas Station Solution 30.80% Medium
135 Candy Solution 25.70% Hard
136 Single Number Solution 56.40% Easy
137 Single Number II Solution 43.30% Medium
138 Copy List with Random Pointer Solution 25.70% Medium
139 Word Break Solution 32.10% Medium
140 Word Break II Solution 25.00% Hard
141 Linked List Cycle Solution 34.80% Easy
142 Linked List Cycle II Solution 30.20% Medium
143 Reorder List Solution 27.50% Medium
144 Binary Tree Preorder Traversal Solution 47.80% Medium
145 Binary Tree Postorder Traversal Solution 43.60% Hard
146 LRU Cache Solution 20.70% Hard
147 Insertion Sort List Solution 34.60% Medium
148 Sort List Solution 31.00% Medium
149 Max Points on a Line Solution 15.20% Hard
150 Evaluate Reverse Polish Notation Solution 29.20% Medium
151 Reverse Words in a String Solution 15.70% Medium
152 Maximum Product Subarray Solution 27.20% Medium
153 Find Minimum in Rotated Sorted Array Solution 41.30% Medium
154 Find Minimum in Rotated Sorted Array II Solution 38.20% Hard
155 Min Stack Solution 32.40% Easy
156 Binary Tree Upside Down Solution 47.00% Medium
157 Read N Characters Given Read4 Solution 28.50% Easy
158 Read N Characters Given Read4 II - Call multiple times Solution 24.50% Hard
159 Longest Substring with At Most Two Distinct Characters Solution 43.40% Hard
160 Intersection of Two Linked Lists Solution 30.80% Easy
161 One Edit Distance Solution 31.40% Medium
162 Find Peak Element Solution 39.50% Medium
163 Missing Ranges Solution 22.90% Medium
164 Maximum Gap Solution 30.60% Hard
165 Compare Version Numbers Solution 21.20% Medium
166 Fraction to Recurring Decimal Solution 18.40% Medium
167 Two Sum II - Input array is sorted Solution 47.40% Easy
168 Excel Sheet Column Title Solution 27.70% Easy
169 Majority Element Solution 49.00% Easy
170 Two Sum III - Data structure design Solution 27.10% Easy
171 Excel Sheet Column Number Solution 49.30% Easy
172 Factorial Trailing Zeroes Solution 37.00% Easy
173 Binary Search Tree Iterator Solution 44.20% Medium
174 Dungeon Game Solution 24.90% Hard
179 Largest Number Solution 23.90% Medium
186 Reverse Words in a String II Solution 32.20% Medium
187 Repeated DNA Sequences Solution 33.70% Medium
188 Best Time to Buy and Sell Stock IV Solution 25.20% Hard
189 Rotate Array Solution 26.30% Easy
190 Reverse Bits Solution 29.30% Easy
191 Number of 1 Bits Solution 40.70% Easy
198 House Robber Solution 40.30% Easy
199 Binary Tree Right Side View Solution 43.60% Medium
200 Number of Islands Solution 37.50% Medium
201 Bitwise AND of Numbers Range Solution 34.80% Medium
202 Happy Number Solution 42.40% Easy
203 Remove Linked List Elements Solution 34.00% Easy
204 Count Primes Solution 26.80% Easy
205 Isomorphic Strings Solution 35.20% Easy
206 Reverse Linked List Solution 48.30% Easy
207 Course Schedule Solution 34.40% Medium
208 Implement Trie (Prefix Tree) Solution 32.40% Medium
209 Minimum Size Subarray Sum Solution 32.80% Medium
210 Course Schedule II Solution 31.10% Medium
211 Add and Search Word - Data structure design Solution 26.30% Medium
212 Word Search II Solution 25.50% Hard
213 House Robber II Solution 34.70% Medium
214 Shortest Palindrome Solution 25.60% Hard
215 Kth Largest Element in an Array Solution 41.90% Medium
216 Combination Sum III Solution 48.20% Medium
217 Contains Duplicate Solution 48.10% Easy
218 The Skyline Problem Solution 29.50% Hard
219 Contains Duplicate II Solution 33.30% Easy
220 Contains Duplicate III Solution 18.80% Medium
221 Maximal Square Solution 30.90% Medium
222 Count Complete Tree Nodes Solution 28.30% Medium
224 Basic Calculator Solution 29.30% Hard
225 Implement Stack using Queues Solution 35.20% Easy
226 Invert Binary Tree Solution 54.40% Easy
227 Basic Calculator II Solution 30.60% Medium
228 Summary Ranges Solution 33.10% Medium
229 Majority Element II Solution 29.80% Medium
230 Kth Smallest Element in a BST Solution 46.50% Medium
231 Power of Two Solution 41.00% Easy
232 Implement Queue using Stacks Solution 39.00% Easy
233 Number of Digit One Solution 29.20% Hard
234 Palindrome Linked List Solution 33.90% Easy
235 Lowest Common Ancestor of a Binary Search Tree Solution 40.60% Easy
236 Lowest Common Ancestor of a Binary Tree Solution 30.80% Medium
237 Delete Node in a Linked List Solution 48.30% Easy
238 Product of Array Except Self Solution 51.10% Medium
239 Sliding Window Maximum Solution 34.80% Hard
240 Search a 2D Matrix II Solution 39.20% Medium
241 Different Ways to Add Parentheses Solution 46.80% Medium
243 Shortest Word Distance Solution 54.20% Easy
244 Shortest Word Distance II Solution 42.30% Medium
245 Shortest Word Distance III Solution 51.70% Medium
246 Strobogrammatic Number Solution 40.50% Easy
247 Strobogrammatic Number II Solution 41.40% Medium
248 Strobogrammatic Number III Solution 33.10% Hard
249 Group Shifted Strings Solution 45.40% Medium
250 Count Univalue Subtrees Solution 44.90% Medium
251 Flatten 2D Vector Solution 41.80% Medium
252 Meeting Rooms Solution 49.40% Easy
253 Meeting Rooms II Solution 39.80% Medium
254 Factor Combinations Solution 43.70% Medium
255 Verify Preorder Sequence in Binary Search Tree Solution 41.30% Medium
256 Paint House Solution 46.60% Easy
257 Binary Tree Paths Solution 42.40% Easy
258 Add Digits Solution 52.30% Easy
259 3Sum Smaller Solution 42.50% Medium
260 Single Number III Solution 54.00% Medium
261 Graph Valid Tree Solution 38.50% Medium
263 Ugly Number Solution 39.90% Easy
264 Ugly Number II Solution 33.80% Medium
265 Paint House II Solution 39.00% Hard
266 Palindrome Permutation Solution 58.40% Easy
267 Palindrome Permutation II Solution 32.20% Medium
268 Missing Number Solution 45.70% Easy
269 Alien Dictionary Solution 27.00% Hard
270 Closest Binary Search Tree Value Solution 41.30% Easy
271 Encode and Decode Strings Solution 25.90% Medium
272 Closest Binary Search Tree Value II Solution 40.80% Hard
273 Integer to English Words Solution 23.00% Hard
274 H-Index Solution 34.00% Medium
275 H-Index II Solution 35.10% Medium
276 Paint Fence Solution 35.20% Easy
277 Find the Celebrity Solution 35.40% Medium
278 First Bad Version Solution 26.50% Easy
279 Perfect Squares Solution 38.30% Medium
280 Wiggle Sort Solution 58.90% Medium
281 Zigzag Iterator Solution 53.40% Medium
282 Expression Add Operators Solution 30.80% Hard
283 Move Zeroes Solution 52.10% Easy
284 Peeking Iterator Solution 36.20% Medium
285 Inorder Successor in BST Solution 34.50% Medium
286 Walls and Gates Solution 46.00% Medium
287 Find the Duplicate Number Solution 45.30% Medium
288 Unique Word Abbreviation Solution 18.40% Medium
289 Game of Life Solution 38.30% Medium
290 Word Pattern Solution 33.80% Easy
291 Word Pattern II Solution 38.70% Hard
292 Nim Game Solution 55.40% Easy
293 Flip Game Solution 57.60% Easy
294 Flip Game II Solution 47.10% Medium
295 Find Median from Data Stream Solution 30.70% Hard
296 Best Meeting Point Solution 52.60% Hard
297 Serialize and Deserialize Binary Tree Solution 35.80% Hard
298 Binary Tree Longest Consecutive Sequence Solution 42.20% Medium
299 Bulls and Cows Solution 36.50% Medium
300 Longest Increasing Subsequence Solution 39.10% Medium
301 Remove Invalid Parentheses Solution 36.20% Hard
302 Smallest Rectangle Enclosing Black Pixels Solution 47.20% Hard
303 Range Sum Query - Immutable Solution 33.40% Easy
304 Range Sum Query 2D - Immutable Solution 28.00% Medium
305 Number of Islands II Solution 39.80% Hard
306 Additive Number Solution 27.80% Medium
307 Range Sum Query - Mutable Solution 23.60% Medium
308 Range Sum Query 2D - Mutable Solution 27.20% Hard
309 Best Time to Buy and Sell Stock with Cooldown Solution 42.50% Medium
310 Minimum Height Trees Solution 29.00% Medium
311 Sparse Matrix Multiplication Solution 53.10% Medium
312 Burst Balloons Solution 44.10% Hard
313 Super Ugly Number Solution 38.90% Medium
314 Binary Tree Vertical Order Traversal Solution 38.30% Medium
315 Count of Smaller Numbers After Self Solution 35.30% Hard
316 Remove Duplicate Letters Solution 30.80% Hard
317 Shortest Distance from All Buildings Solution 34.90% Hard
318 Maximum Product of Word Lengths Solution 46.40% Medium
319 Bulb Switcher Solution 43.20% Medium
320 Generalized Abbreviation Solution 46.70% Medium
321 Create Maximum Number Solution 24.90% Hard
322 Coin Change Solution 26.90% Medium
323 Number of Connected Components in an Undirected Graph Solution 49.30% Medium
324 Wiggle Sort II Solution 26.50% Medium
325 Maximum Size Subarray Sum Equals k Solution 43.30% Medium
326 Power of Three Solution 40.90% Easy
327 Count of Range Sum Solution 31.00% Hard
328 Odd Even Linked List Solution 45.80% Medium
329 Longest Increasing Path in a Matrix Solution 37.60% Hard
330 Patching Array Solution 32.90% Hard
331 Verify Preorder Serialization of a Binary Tree Solution 37.50% Medium
332 Reconstruct Itinerary Solution 30.00% Medium
333 Largest BST Subtree Solution 31.40% Medium
334 Increasing Triplet Subsequence Solution 39.60% Medium
335 Self Crossing Solution 26.40% Hard
336 Palindrome Pairs Solution 27.60% Hard
337 House Robber III Solution 45.40% Medium
338 Counting Bits Solution 62.70% Medium
339 Nested List Weight Sum Solution 64.30% Easy
340 Longest Substring with At Most K Distinct Characters Solution 38.30% Hard
341 Flatten Nested List Iterator Solution 43.90% Medium
342 Power of Four Solution 39.40% Easy
343 Integer Break Solution 46.70% Medium
344 Reverse String Solution 61.00% Easy
345 Reverse Vowels of a String Solution 39.60% Easy
346 Moving Average from Data Stream Solution 61.20% Easy
347 Top K Frequent Elements Solution 50.40% Medium
348 Design Tic-Tac-Toe Solution 46.40% Medium
349 Intersection of Two Arrays Solution 48.70% Easy
350 Intersection of Two Arrays II Solution 44.20% Easy
351 Android Unlock Patterns Solution 44.60% Medium
352 Data Stream as Disjoint Intervals Solution 41.30% Hard
353 Design Snake Game Solution 27.50% Medium
354 Russian Doll Envelopes Solution 32.70% Hard
355 Design Twitter Solution 26.00% Medium
356 Line Reflection Solution 30.40% Medium
357 Count Numbers with Unique Digits Solution 46.20% Medium
358 Rearrange String k Distance Apart Solution 31.80% Hard
359 Logger Rate Limiter Solution 61.40% Easy
360 Sort Transformed Array Solution 45.20% Medium
361 Bomb Enemy Solution 40.80% Medium
362 Design Hit Counter Solution 55.60% Medium
363 Max Sum of Rectangle No Larger Than K Solution 34.00% Hard
364 Nested List Weight Sum II Solution 54.20% Medium
365 Water and Jug Problem Solution 28.30% Medium
366 Find Leaves of Binary Tree Solution 61.70% Medium
367 Valid Perfect Square Solution 38.80% Easy
368 Largest Divisible Subset Solution 33.90% Medium
369 Plus One Linked List Solution 54.90% Medium
370 Range Addition Solution 57.70% Medium
371 Sum of Two Integers Solution 50.80% Easy
372 Super Pow Solution 34.80% Medium
373 Find K Pairs with Smallest Sums Solution 31.70% Medium
374 Guess Number Higher or Lower Solution 37.30% Easy
375 Guess Number Higher or Lower II Solution 36.20% Medium
376 Wiggle Subsequence Solution 36.20% Medium
377 Combination Sum IV Solution 43.00% Medium
378 Kth Smallest Element in a Sorted Matrix Solution 45.90% Medium
379 Design Phone Directory Solution 37.20% Medium
380 Insert Delete GetRandom O(1) Solution 40.30% Medium
381 Insert Delete GetRandom O(1) - Duplicates allowed Solution 29.90% Hard
382 Linked List Random Node Solution 47.70% Medium
383 Ransom Note Solution 48.10% Easy
384 Shuffle an Array Solution 47.60% Medium
385 Mini Parser Solution 31.00% Medium
386 Lexicographical Numbers Solution 42.90% Medium
387 First Unique Character in a String Solution 47.30% Easy
388 Longest Absolute File Path Solution 37.70% Medium
389 Find the Difference Solution 51.70% Easy
390 Elimination Game Solution 42.70% Medium
391 Perfect Rectangle Solution 27.70% Hard
392 Is Subsequence Solution 44.70% Medium
393 UTF-8 Validation Solution 34.90% Medium
394 Decode String Solution 42.20% Medium
395 Longest Substring with At Least K Repeating Characters Solution 35.80% Medium
396 Rotate Function Solution 34.20% Medium
397 Integer Replacement Solution 30.60% Medium
398 Random Pick Index Solution 45.30% Medium
399 Evaluate Division Solution 42.90% Medium
400 Nth Digit Solution 29.90% Easy
401 Binary Watch Solution 44.80% Easy
402 Remove K Digits Solution 25.80% Medium
403 Frog Jump Solution 32.80% Hard
404 Sum of Left Leaves Solution 47.90% Easy
405 Convert a Number to Hexadecimal Solution 41.10% Easy
406 Queue Reconstruction by Height Solution 56.80% Medium
407 Trapping Rain Water II Solution 37.80% Hard
408 Valid Word Abbreviation Solution 28.40% Easy
409 Longest Palindrome Solution 46.20% Easy
410 Split Array Largest Sum Solution 39.80% Hard
411 Minimum Unique Word Abbreviation Solution 33.70% Hard
412 Fizz Buzz Solution 58.00% Easy
413 Arithmetic Slices Solution 54.50% Medium
414 Third Maximum Number Solution 28.20% Easy
415 Add Strings Solution 41.80% Easy
416 Partition Equal Subset Sum Solution 38.70% Medium
417 Pacific Atlantic Water Flow Solution 35.10% Medium
418 Sentence Screen Fitting Solution 28.70% Medium
419 Battleships in a Board Solution 63.70% Medium
420 Strong Password Checker Solution 19.20% Hard
421 Maximum XOR of Two Numbers in an Array Solution 48.60% Medium
422 Valid Word Square Solution 36.50% Easy
423 Reconstruct Original Digits from English Solution 44.90% Medium
424 Longest Repeating Character Replacement Solution 42.50% Medium
425 Word Squares Solution 42.90% Hard
426 Convert Binary Search Tree to Sorted Doubly Linked List Solution 18.50% Medium
427 Construct Quad Tree Solution 43.10% Easy
428 Serialize and Deserialize N-ary Tree Solution 26.40% Hard
429 N-ary Tree Level Order Traversal Solution 42.80% Easy
430 Flatten a Multilevel Doubly Linked List Solution 23.50% Medium
431 Encode N-ary Tree to Binary Tree Solution 28.50% Hard
432 All O`one Data Structure Solution 27.80% Hard
433 Minimum Genetic Mutation Solution 35.50% Medium
434 Number of Segments in a String Solution 36.60% Easy
435 Non-overlapping Intervals Solution 41.10% Medium
436 Find Right Interval Solution 41.70% Medium
437 Path Sum III Solution 40.30% Easy
438 Find All Anagrams in a String Solution 34.00% Easy
439 Ternary Expression Parser Solution 51.60% Medium
440 K-th Smallest in Lexicographical Order Solution 25.80% Hard
441 Arranging Coins Solution 36.70% Easy
442 Find All Duplicates in an Array Solution 57.70% Medium
443 String Compression Solution 35.80% Easy
444 Sequence Reconstruction Solution 19.60% Medium
445 Add Two Numbers II Solution 46.80% Medium
446 Arithmetic Slices II - Subsequence Solution 28.00% Hard
447 Number of Boomerangs Solution 47.20% Easy
448 Find All Numbers Disappeared in an Array Solution 51.30% Easy
449 Serialize and Deserialize BST Solution 42.90% Medium
450 Delete Node in a BST Solution 37.60% Medium
451 Sort Characters By Frequency Solution 52.40% Medium
452 Minimum Number of Arrows to Burst Balloons Solution 44.60% Medium
453 Minimum Moves to Equal Array Elements Solution 48.10% Easy
454 4Sum II Solution 47.80% Medium
455 Assign Cookies Solution 47.40% Easy
456 132 Pattern Solution 27.60% Medium
457 Circular Array Loop Solution 23.20% Medium
458 Poor Pigs Solution 43.00% Easy
459 Repeated Substring Pattern Solution 38.40% Easy
460 LFU Cache Solution 25.60% Hard
461 Hamming Distance Solution 69.50% Easy
462 Minimum Moves to Equal Array Elements II Solution 51.80% Medium
463 Island Perimeter Solution 58.20% Easy
464 Can I Win Solution 26.00% Medium
465 Optimal Account Balancing Solution 39.80% Hard
466 Count The Repetitions Solution 27.30% Hard
467 Unique Substrings in Wraparound String Solution 33.30% Medium
468 Validate IP Address Solution 20.50% Medium
469 Convex Polygon Solution 34.80% Medium
470 Implement Rand10() Using Rand7() Solution 42.10% Medium
471 Encode String with Shortest Length Solution 43.60% Hard
472 Concatenated Words Solution 31.60% Hard
473 Matchsticks to Square Solution 35.40% Medium
474 Ones and Zeroes Solution 38.80% Medium
475 Heaters Solution 29.80% Easy
476 Number Complement Solution 61.30% Easy
477 Total Hamming Distance Solution 47.80% Medium
479 Largest Palindrome Product Solution 25.90% Easy
480 Sliding Window Median Solution 30.80% Hard
481 Magical String Solution 45.70% Medium
482 License Key Formatting Solution 39.20% Easy
483 Smallest Good Base Solution 33.90% Hard
484 Find Permutation Solution 55.70% Medium
485 Max Consecutive Ones Solution 53.70% Easy
486 Predict the Winner Solution 45.40% Medium
487 Max Consecutive Ones II Solution 45.40% Medium
488 Zuma Game Solution 36.70% Hard
489 Robot Room Cleaner Solution 31.50% Hard
490 The Maze Solution 43.90% Medium
491 Increasing Subsequences Solution 39.10% Medium
492 Construct the Rectangle Solution 48.00% Easy
493 Reverse Pairs Solution 20.80% Hard
494 Target Sum Solution 44.00% Medium
495 Teemo Attacking Solution 51.50% Medium
496 Next Greater Element I Solution 56.80% Easy
498 Diagonal Traverse Solution 44.60% Medium
499 The Maze III Solution 34.30% Hard
500 Keyboard Row Solution 60.30% Easy
501 Find Mode in Binary Search Tree Solution 37.80% Easy
502 IPO Solution 36.40% Hard
503 Next Greater Element II Solution 48.20% Medium
504 Base 7 Solution 43.90% Easy
505 The Maze II Solution 39.00% Medium
506 Relative Ranks Solution 47.10% Easy
507 Perfect Number Solution 32.70% Easy
508 Most Frequent Subtree Sum Solution 52.60% Medium
513 Find Bottom Left Tree Value Solution 56.50% Medium
514 Freedom Trail Solution 39.40% Hard
515 Find Largest Value in Each Tree Row Solution 56.00% Medium
516 Longest Palindromic Subsequence Solution 43.30% Medium
517 Super Washing Machines Solution 36.40% Hard
518 Coin Change 2 Solution 36.30% Medium
520 Detect Capital Solution 51.90% Easy
521 Longest Uncommon Subsequence I Solution 55.80% Easy
522 Longest Uncommon Subsequence II Solution 32.20% Medium
523 Continuous Subarray Sum Solution 23.40% Medium
524 Longest Word in Dictionary through Deleting Solution 43.50% Medium
525 Contiguous Array Solution 41.80% Medium
526 Beautiful Arrangement Solution 53.00% Medium
527 Word Abbreviation Solution 44.50% Hard
529 Minesweeper Solution 49.60% Medium
530 Minimum Absolute Difference in BST Solution 48.10% Easy
531 Lonely Pixel I Solution 56.50% Medium
532 K-diff Pairs in an Array Solution 28.40% Easy
533 Lonely Pixel II Solution 45.40% Medium
535 Encode and Decode TinyURL Solution 74.00% Medium
536 Construct Binary Tree from String Solution 42.80% Medium
537 Complex Number Multiplication Solution 64.10% Medium
538 Convert BST to Greater Tree Solution 48.70% Easy
539 Minimum Time Difference Solution 46.20% Medium
540 Single Element in a Sorted Array Solution 56.10% Medium
541 Reverse String II Solution 44.10% Easy
542 01 Matrix Solution 33.30% Medium
543 Diameter of Binary Tree Solution 45.20% Easy
544 Output Contest Matches Solution 71.60% Medium
545 Boundary of Binary Tree Solution 32.70% Medium
546 Remove Boxes Solution 36.10% Hard
547 Friend Circles Solution 49.60% Medium
548 Split Array with Equal Sum Solution 38.10% Medium
549 Binary Tree Longest Consecutive Sequence II Solution 42.80% Medium
551 Student Attendance Record I Solution 44.80% Easy
552 Student Attendance Record II Solution 31.80% Hard
553 Optimal Division Solution 55.20% Medium
554 Brick Wall Solution 46.60% Medium
555 Split Concatenated Strings Solution 38.10% Medium
556 Next Greater Element III Solution 28.80% Medium
557 Reverse Words in a String III Solution 60.90% Easy
558 Quad Tree Intersection Solution 23.90% Easy
559 Maximum Depth of N-ary Tree Solution 50.10% Easy
560 Subarray Sum Equals K Solution 39.90% Medium
561 Array Partition I Solution 66.80% Easy
562 Longest Line of Consecutive One in Matrix Solution 41.10% Medium
563 Binary Tree Tilt Solution 46.90% Easy
564 Find the Closest Palindrome Solution 16.80% Hard
565 Array Nesting Solution 49.90% Medium
566 Reshape the Matrix Solution 57.70% Easy
567 Permutation in String Solution 36.20% Medium
568 Maximum Vacation Days Solution 36.40% Hard
572 Subtree of Another Tree Solution 40.30% Easy
573 Squirrel Simulation Solution 52.50% Medium
575 Distribute Candies Solution 58.20% Easy
576 Out of Boundary Paths Solution 30.60% Medium
581 Shortest Unsorted Continuous Subarray Solution 29.30% Easy
582 Kill Process Solution 51.90% Medium
583 Delete Operation for Two Strings Solution 44.80% Medium
587 Erect the Fence Solution 33.70% Hard
588 Design In-Memory File System Solution 36.30% Hard
589 N-ary Tree Preorder Traversal Solution 41.60% Easy
590 N-ary Tree Postorder Traversal Solution 47.00% Easy
591 Tag Validator Solution 31.10% Hard
592 Fraction Addition and Subtraction Solution 46.10% Medium
593 Valid Square Solution 39.90% Medium
594 Longest Harmonious Subsequence Solution 41.40% Easy
598 Range Addition II Solution 48.00% Easy
599 Minimum Index Sum of Two Lists Solution 46.50% Easy
600 Non-negative Integers without Consecutive Ones Solution 31.90% Hard
604 Design Compressed String Iterator Solution 33.60% Easy
605 Can Place Flowers Solution 30.00% Easy
606 Construct String from Binary Tree Solution 50.20% Easy
609 Find Duplicate File in System Solution 52.50% Medium
611 Valid Triangle Number Solution 42.00% Medium
616 Add Bold Tag in String Solution 38.10% Medium
617 Merge Two Binary Trees Solution 68.10% Easy
621 Task Scheduler Solution 42.50% Medium
622 Design Circular Queue Solution 39.70% Medium
623 Add One Row to Tree Solution 46.10% Medium
624 Maximum Distance in Arrays Solution 35.80% Easy
625 Minimum Factorization Solution 31.30% Medium
628 Maximum Product of Three Numbers Solution 44.80% Easy
629 K Inverse Pairs Array Solution 27.80% Hard
630 Course Schedule III Solution 29.40% Hard
631 Design Excel Sum Formula Solution 28.40% Hard
632 Smallest Range Solution 42.80% Hard
633 Sum of Square Numbers Solution 32.40% Easy
634 Find the Derangement of An Array Solution 36.30% Medium
635 Design Log Storage System Solution 49.60% Medium
636 Exclusive Time of Functions Solution 44.80% Medium
637 Average of Levels in Binary Tree Solution 56.30% Easy
638 Shopping Offers Solution 46.00% Medium
639 Decode Ways II Solution 24.20% Hard
640 Solve the Equation Solution 38.70% Medium
641 Design Circular Deque Solution 51.40% Medium
642 Design Search Autocomplete System Solution 30.60% Hard
643 Maximum Average Subarray I Solution 37.80% Easy
644 Maximum Average Subarray II Solution 25.70% Hard
645 Set Mismatch Solution 39.70% Easy
646 Maximum Length of Pair Chain Solution 47.50% Medium
647 Palindromic Substrings Solution 54.40% Medium
648 Replace Words Solution 48.50% Medium
649 Dota2 Senate Solution 36.90% Medium
650 2 Keys Keyboard Solution 45.50% Medium
651 4 Keys Keyboard Solution 49.90% Medium
652 Find Duplicate Subtrees Solution 38.00% Medium
653 Two Sum IV - Input is a BST Solution 50.30% Easy
654 Maximum Binary Tree Solution 70.70% Medium
655 Print Binary Tree Solution 48.80% Medium
656 Coin Path Solution 25.70% Hard
657 Judge Route Circle Solution 68.70% Easy
658 Find K Closest Elements Solution 34.60% Medium
659 Split Array into Consecutive Subsequences Solution 37.30% Medium
660 Remove 9 Solution 50.10% Hard
661 Image Smoother Solution 46.80% Easy
662 Maximum Width of Binary Tree Solution 38.30% Medium
663 Equal Tree Partition Solution 36.40% Medium
664 Strange Printer Solution 34.80% Hard
665 Non-decreasing Array Solution 19.90% Easy
666 Path Sum IV Solution 50.70% Medium
667 Beautiful Arrangement II Solution 51.00% Medium
668 Kth Smallest Number in Multiplication Table Solution 40.50% Hard
669 Trim a Binary Search Tree Solution 58.10% Easy
670 Maximum Swap Solution 38.80% Medium
671 Second Minimum Node In a Binary Tree Solution 42.10% Easy
672 Bulb Switcher II Solution 48.90% Medium
673 Number of Longest Increasing Subsequence Solution 32.00% Medium
674 Longest Continuous Increasing Subsequence Solution 42.70% Easy
675 Cut Off Trees for Golf Event Solution 27.20% Hard
676 Implement Magic Dictionary Solution 49.10% Medium
677 Map Sum Pairs Solution 50.80% Medium
678 Valid Parenthesis String Solution 29.60% Medium
679 24 Game Solution 39.00% Hard
680 Valid Palindrome II Solution 32.30% Easy
681 Next Closest Time Solution 41.60% Medium
682 Baseball Game Solution 58.40% Easy
683 K Empty Slots Solution 33.50% Hard
684 Redundant Connection Solution 45.00% Medium
685 Redundant Connection II Solution 27.70% Hard
686 Repeated String Match Solution 31.50% Easy
687 Longest Univalue Path Solution 32.70% Easy
688 Knight Probability in Chessboard Solution 40.60% Medium
689 Maximum Sum of 3 Non-Overlapping Subarrays Solution 41.40% Hard
690 Employee Importance Solution 51.80% Easy
691 Stickers to Spell Word Solution 35.40% Hard
692 Top K Frequent Words Solution 41.90% Medium
693 Binary Number with Alternating Bits Solution 56.20% Easy
694 Number of Distinct Islands Solution 45.40% Medium
695 Max Area of Island Solution 52.20% Easy
696 Count Binary Substrings Solution 51.10% Easy
697 Degree of an Array Solution 47.10% Easy
698 Partition to K Equal Sum Subsets Solution 38.30% Medium
699 Falling Squares Solution 38.10% Hard
700 Search in a Binary Search Tree Solution 42.40% Easy
701 Insert into a Binary Search Tree Solution 38.00% Medium
702 Search in a Sorted Array of Unknown Size Solution 29.20% Medium
703 Kth Largest Element in a Stream Solution 23.90% Easy
704 Binary Search Solution 19.20% Easy
705 Design HashSet Solution 19.90% Easy
706 Design HashMap Solution 28.20% Easy
707 Design Linked List Solution 10.20% Easy
708 Insert into a Cyclic Sorted List Solution 10.90% Medium
709 To Lower Case Solution 75.50% Easy
710 Random Pick with Blacklist Solution 29.30% Hard
711 Number of Distinct Islands II Solution 42.50% Hard
712 Minimum ASCII Delete Sum for Two Strings Solution 51.50% Medium
713 Subarray Product Less Than K Solution 33.30% Medium
714 Best Time to Buy and Sell Stock with Transaction Fee Solution 47.20% Medium
715 Range Module Solution 30.80% Hard
716 Max Stack Solution 36.70% Hard
717 1-bit and 2-bit Characters Solution 49.00% Easy
718 Maximum Length of Repeated Subarray Solution 42.00% Medium
719 Find K-th Smallest Pair Distance Solution 27.70% Hard
720 Longest Word in Dictionary Solution 41.60% Easy
721 Accounts Merge Solution 34.20% Medium
722 Remove Comments Solution 28.00% Medium
723 Candy Crush Solution 55.90% Medium
724 Find Pivot Index Solution 39.20% Easy
725 Split Linked List in Parts Solution 47.10% Medium
726 Number of Atoms Solution 43.70% Hard
727 Minimum Window Subsequence Solution 32.00% Hard
728 Self Dividing Numbers Solution 67.00% Easy
729 My Calendar I Solution 42.90% Medium
730 Count Different Palindromic Subsequences Solution 35.80% Hard
731 My Calendar II Solution 38.80% Medium
732 My Calendar III Solution 50.20% Hard
733 Flood Fill Solution 47.70% Easy
734 Sentence Similarity Solution 39.00% Easy
735 Asteroid Collision Solution 37.00% Medium
736 Parse Lisp Expression Solution 41.90% Hard
737 Sentence Similarity II Solution 40.40% Medium
738 Monotone Increasing Digits Solution 41.30% Medium
739 Daily Temperatures Solution 53.90% Medium
740 Delete and Earn Solution 44.00% Medium
741 Cherry Pickup Solution 24.40% Hard
742 Closest Leaf in a Binary Tree Solution 35.00% Medium
743 Network Delay Time Solution 36.20% Medium
744 Find Smallest Letter Greater Than Target Solution 43.20% Easy
745 Prefix and Suffix Search Solution 26.30% Hard
746 Min Cost Climbing Stairs Solution 43.80% Easy
747 Largest Number At Least Twice of Others Solution 40.40% Easy
748 Shortest Completing Word Solution 52.40% Medium
749 Contain Virus Solution 40.30% Hard
750 Number Of Corner Rectangles Solution 57.90% Medium
751 IP to CIDR Solution 53.30% Easy
752 Open the Lock Solution 40.80% Medium
753 Cracking the Safe Solution 41.40% Hard
754 Reach a Number Solution 28.30% Medium
755 Pour Water Solution 35.20% Medium
756 Pyramid Transition Matrix Solution 47.30% Medium
757 Set Intersection Size At Least Two Solution 34.80% Hard
758 Bold Words in String Solution 39.70% Easy
759 Employee Free Time Solution 53.70% Hard
760 Find Anagram Mappings Solution 76.60% Easy
761 Special Binary String Solution 44.40% Hard
762 Prime Number of Set Bits in Binary Representation Solution 55.80% Easy
763 Partition Labels Solution 64.90% Medium
764 Largest Plus Sign Solution 40.30% Medium
765 Couples Holding Hands Solution 48.60% Hard
766 Toeplitz Matrix Solution 58.20% Easy
767 Reorganize String Solution 37.30% Medium
768 Max Chunks To Make Sorted II Solution 43.20% Hard
769 Max Chunks To Make Sorted Solution 48.50% Medium
770 Basic Calculator IV Solution 42.60% Hard
772 Basic Calculator III Solution 40.50% Hard
773 Sliding Puzzle Solution 46.40% Hard
774 Minimize Max Distance to Gas Station Solution 34.00% Hard
775 Global and Local Inversions Solution 34.70% Medium
776 Split BST Solution 49.40% Medium
777 Swap Adjacent in LR String Solution 29.20% Medium
778 Swim in Rising Water Solution 44.30% Hard
779 K-th Symbol in Grammar Solution 37.20% Medium
780 Reaching Points Solution 24.40% Hard
781 Rabbits in Forest Solution 49.60% Medium
782 Transform to Chessboard Solution 37.60% Hard
783 Minimum Distance Between BST Nodes Solution 48.00% Easy
784 Letter Case Permutation Solution 53.20% Easy
785 Is Graph Bipartite? Solution 38.80% Medium
786 K-th Smallest Prime Fraction Solution 33.40% Hard
787 Cheapest Flights Within K Stops Solution 30.00% Medium
788 Rotated Digits Solution 51.10% Easy
789 Escape The Ghosts Solution 52.10% Medium
790 Domino and Tromino Tiling Solution 33.20% Medium
791 Custom Sort String Solution 59.40% Medium
792 Number of Matching Subsequences Solution 37.10% Medium
793 Preimage Size of Factorial Zeroes Function Solution 41.10% Hard
794 Valid Tic-Tac-Toe State Solution 27.70% Medium
795 Number of Subarrays with Bounded Maximum Solution 41.50% Medium
796 Rotate String Solution 49.70% Easy
797 All Paths From Source to Target Solution 67.20% Medium
798 Smallest Rotation with Highest Score Solution 34.30% Hard
799 Champagne Tower Solution 29.90% Medium
800 Similar RGB Color Solution 54.60% Easy
801 Minimum Swaps To Make Sequences Increasing Solution 30.60% Medium
802 Find Eventual Safe States Solution 39.00% Medium
803 Bricks Falling When Hit Solution 22.80% Hard
804 Unique Morse Code Words Solution 71.30% Easy
805 Split Array With Same Average Solution 20.90% Hard
806 Number of Lines To Write String Solution 62.10% Easy
807 Max Increase to Keep City Skyline Solution 79.70% Medium
808 Soup Servings Solution 33.60% Medium
809 Expressive Words Solution 37.70% Medium
810 Chalkboard XOR Game Solution 39.50% Hard
811 Subdomain Visit Count Solution 61.30% Easy
812 Largest Triangle Area Solution 53.30% Easy
813 Largest Sum of Averages Solution 41.10% Medium
814 Binary Tree Pruning Solution 68.40% Medium
815 Bus Routes Solution 32.70% Hard
816 Ambiguous Coordinates Solution 42.20% Medium
817 Linked List Components Solution 50.80% Medium
818 Race Car Solution 28.10% Hard
819 Most Common Word Solution 48.70% Easy
820 Short Encoding of Words Solution 42.60% Medium
821 Shortest Distance to a Character Solution 60.80% Easy
822 Card Flipping Game Solution 36.10% Medium
823 Binary Trees With Factors Solution 29.30% Medium
824 Goat Latin Solution 55.00% Easy
825 Friends Of Appropriate Ages Solution 30.10% Medium
826 Most Profit Assigning Work Solution 32.20% Medium
827 Making A Large Island Solution 40.00% Hard
828 Unique Letter String Solution 34.00% Hard
829 Consecutive Numbers Sum Solution 26.80% Medium
830 Positions of Large Groups Solution 46.60% Easy
831 Masking Personal Information Solution 42.10% Medium
832 Flipping an Image Solution 69.20% Easy
833 Find And Replace in String Solution 38.30% Medium
834 Sum of Distances in Tree Solution 32.60% Hard
835 Image Overlap Solution 39.80% Medium
836 Rectangle Overlap Solution 42.00% Easy
837 New 21 Game Solution 25.80% Medium
838 Push Dominoes Solution 40.40% Medium
839 Similar String Groups Solution 33.30% Hard
840 Magic Squares In Grid Solution 34.30% Easy
841 Keys and Rooms Solution 56.70% Medium
842 Split Array into Fibonacci Sequence Solution 34.20% Medium
843 Guess the Word Solution 33.90% Hard
844 Backspace String Compare Solution 45.40% Easy
845 Longest Mountain in Array Solution 31.40% Medium
846 Hand of Straights Solution 42.70% Medium
847 Shortest Path Visiting All Nodes Solution 40.90% Hard
848 Shifting Letters Solution 35.10% Medium
849 Maximize Distance to Closest Person Solution 38.10% Easy
850 Rectangle Area II Solution 42.10% Hard
851 Loud and Rich Solution 42.90% Medium
852 Peak Index in a Mountain Array Solution 68.00% Easy
853 Car Fleet Solution 31.00% Medium
854 K-Similar Strings Solution 30.10% Hard
855 Exam Room Solution 29.30% Medium
856 Score of Parentheses Solution 54.10% Medium
857 Minimum Cost to Hire K Workers Solution 38.70% Hard
858 Mirror Reflection Solution 47.20% Medium
859 Buddy Strings Solution 26.80% Easy
860 Lemonade Change Solution 49.40% Easy
861 Score After Flipping Matrix Solution 69.10% Medium
862 Shortest Subarray with Sum at Least K Solution 16.50% Hard
863 All Nodes Distance K in Binary Tree Solution 40.20% Medium
864 Shortest Path to Get All Keys Solution 31.00% Hard
865 Smallest Subtree with all the Deepest Nodes Solution 49.40% Medium
866 Prime Palindrome Solution 17.60% Medium
867 Transpose Matrix Solution 66.80% Easy
868 Binary Gap Solution 60.90% Easy
869 Reordered Power of 2 Solution 46.80% Medium
870 Advantage Shuffle Solution 38.60% Medium
871 Minimum Number of Refueling Stops Solution 24.80% Hard
872 Leaf-Similar Trees Solution 64.90% Easy
873 Length of Longest Fibonacci Subsequence Solution 40.60% Medium
874 Walking Robot Simulation Solution 26.20% Easy
875 Koko Eating Bananas Solution 39.60% Medium
876 Middle of the Linked List New Solution 73.80% Easy
877 Stone Game New Solution 40.40% Medium
878 Nth Magical Number New Solution 14.30% Hard
879 Profitable Schemes New Solution 19.10% Hard
880 Random Pick with Weight New Solution 44.50% Medium
881 Random Flip Matrix New Solution 35.20% Medium
882 Random Point in Non-overlapping Rectangles New Solution 32.20% Medium
883 Generate Random Point in a Circle New Solution 29.70% Medium

常用思路

  1. 字符串
  1. 排序

挖坑

希望写完这份javascirpt版之后,能写份c++的

results matching ""

    No results matching ""