LeetCode-in-Go

module
v0.0.0-...-4e682c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2018 License: MIT

README

LeetCode 的 Go 解答

LeetCode 主页 LeetCode 排名 LeetCode 答题进度 codecov Build Status

进度

统计规则:1.免费题,2.算法题,3.能用 Go 解答

Easy Medium Hard Total
Accepted 155 260 109 524
Total 155 260 108 523

题解

题号 题目 通过率 难度 收藏
1 Two Sum 36% Easy
2 Add Two Numbers 28% Medium
3 Longest Substring Without Repeating Characters 24% Medium
4 Median of Two Sorted Arrays 22% Hard
5 Longest Palindromic Substring 25% Medium
6 ZigZag Conversion 27% Medium
7 Reverse Integer 24% Easy
8 String to Integer (atoi) 13% Medium
9 Palindrome Number 35% Easy
10 Regular Expression Matching 24% Hard
11 Container With Most Water 36% Medium
12 Integer to Roman 45% Medium
13 Roman to Integer 47% Easy
14 Longest Common Prefix 31% Easy
15 3Sum 21% Medium
16 3Sum Closest 31% Medium
17 Letter Combinations of a Phone Number 35% Medium
18 4Sum 27% Medium
19 Remove Nth Node From End of List 34% Medium
20 Valid Parentheses 33% Easy
21 Merge Two Sorted Lists 39% Easy
22 Generate Parentheses 46% Medium
23 Merge k Sorted Lists 27% Hard
24 Swap Nodes in Pairs 38% Medium
25 Reverse Nodes in k-Group 31% Hard
26 Remove Duplicates from Sorted Array 35% Easy
27 Remove Element 40% Easy
28 Implement strStr() 28% Easy
29 Divide Two Integers 15% Medium
30 Substring with Concatenation of All Words 22% Hard
31 Next Permutation 28% Medium
32 Longest Valid Parentheses 23% Hard
33 Search in Rotated Sorted Array 32% Medium
34 Search for a Range 31% Medium
35 Search Insert Position 39% Easy
36 Valid Sudoku 36% Medium
37 Sudoku Solver 31% Hard
38 Count and Say 36% Easy
39 Combination Sum 40% Medium
40 Combination Sum II 35% Medium
41 First Missing Positive 25% Hard
42 Trapping Rain Water 37% Hard
43 Multiply Strings 27% Medium
44 Wildcard Matching 20% Hard
45 Jump Game II 26% Hard
46 Permutations 45% Medium
47 Permutations II 34% Medium
48 Rotate Image 40% Medium
49 Group Anagrams 37% Medium
50 Pow(x, n) 26% Medium
51 N-Queens 32% Hard
52 N-Queens II 46% Hard
53 Maximum Subarray 40% Easy
54 Spiral Matrix 26% Medium
55 Jump Game 29% Medium
56 Merge Intervals 31% Medium
57 Insert Interval 28% Hard
58 Length of Last Word 32% Easy
59 Spiral Matrix II 40% Medium
60 Permutation Sequence 29% Medium
61 Rotate List 24% Medium
62 Unique Paths 42% Medium
63 Unique Paths II 32% Medium
64 Minimum Path Sum 39% Medium
65 Valid Number 12% Hard
66 Plus One 39% Easy
67 Add Binary 33% Easy
68 Text Justification 19% Hard
69 Sqrt(x) 28% Easy
70 Climbing Stairs 40% Easy
71 Simplify Path 26% Medium
72 Edit Distance 32% Hard
73 Set Matrix Zeroes 36% Medium
74 Search a 2D Matrix 34% Medium
75 Sort Colors 38% Medium
76 Minimum Window Substring 26% Hard
77 Combinations 40% Medium
78 Subsets 43% Medium
79 Word Search 27% Medium
80 Remove Duplicates from Sorted Array II 36% Medium
81 Search in Rotated Sorted Array II 32% Medium
82 Remove Duplicates from Sorted List II 29% Medium
83 Remove Duplicates from Sorted List 40% Easy
84 Largest Rectangle in Histogram 27% Hard
85 Maximal Rectangle 29% Hard
86 Partition List 33% Medium
87 Scramble String 29% Hard
88 Merge Sorted Array 32% Easy
89 Gray Code 41% Medium
90 Subsets II 37% Medium
91 Decode Ways 20% Medium
92 Reverse Linked List II 31% Medium
93 Restore IP Addresses 28% Medium
94 Binary Tree Inorder Traversal 48% Medium
95 Unique Binary Search Trees II 31% Medium
96 Unique Binary Search Trees 41% Medium
97 Interleaving String 24% Hard
98 Validate Binary Search Tree 23% Medium
99 Recover Binary Search Tree 30% Hard
100 Same Tree 47% Easy
101 Symmetric Tree 39% Easy
102 Binary Tree Level Order Traversal 41% Medium
103 Binary Tree Zigzag Level Order Traversal 35% Medium
104 Maximum Depth of Binary Tree 53% Easy
105 Construct Binary Tree from Preorder and Inorder Traversal 33% Medium
106 Construct Binary Tree from Inorder and Postorder Traversal 32% Medium
107 Binary Tree Level Order Traversal II 41% Easy
108 Convert Sorted Array to Binary Search Tree 43% Easy
109 Convert Sorted List to Binary Search Tree 34% Medium
110 Balanced Binary Tree 38% Easy
111 Minimum Depth of Binary Tree 33% Easy
112 Path Sum 34% Easy
113 Path Sum II 34% Medium
114 Flatten Binary Tree to Linked List 36% Medium
115 Distinct Subsequences 31% Hard
118 Pascal's Triangle 39% Easy
119 Pascal's Triangle II 37% Easy
120 Triangle 34% Medium
121 Best Time to Buy and Sell Stock 42% Easy
122 Best Time to Buy and Sell Stock II 47% Easy
123 Best Time to Buy and Sell Stock III 30% Hard
124 Binary Tree Maximum Path Sum 26% Hard
125 Valid Palindrome 26% Easy
126 Word Ladder II 14% Hard
127 Word Ladder 19% Medium
128 Longest Consecutive Sequence 37% Hard
129 Sum Root to Leaf Numbers 37% Medium
130 Surrounded Regions 19% Medium
131 Palindrome Partitioning 34% Medium
132 Palindrome Partitioning II 24% Hard
134 Gas Station 29% Medium
135 Candy 25% Hard
136 Single Number 55% Easy
137 Single Number II 42% Medium
139 Word Break 31% Medium
140 Word Break II 24% Hard
143 Reorder List 26% Medium
144 Binary Tree Preorder Traversal 46% Medium
145 Binary Tree Postorder Traversal 41% Hard
146 LRU Cache 19% Hard
147 Insertion Sort List 33% Medium
148 Sort List 29% Medium
149 Max Points on a Line 15% Hard
150 Evaluate Reverse Polish Notation 27% Medium
152 Maximum Product Subarray 26% Medium
153 Find Minimum in Rotated Sorted Array 40% Medium
154 Find Minimum in Rotated Sorted Array II 37% Hard
155 Min Stack 30% Easy
162 Find Peak Element 38% Medium
164 Maximum Gap 29% Hard
165 Compare Version Numbers 20% Medium
166 Fraction to Recurring Decimal 17% Medium
167 Two Sum II - Input array is sorted 47% Easy
168 Excel Sheet Column Title 26% Easy
169 Majority Element 47% Easy
171 Excel Sheet Column Number 48% Easy
172 Factorial Trailing Zeroes 36% Easy
174 Dungeon Game 23% Hard
179 Largest Number 23% Medium
187 Repeated DNA Sequences 32% Medium
188 Best Time to Buy and Sell Stock IV 24% Hard
189 Rotate Array 25% Easy
198 House Robber 39% Easy
199 Binary Tree Right Side View 41% Medium
200 Number of Islands 35% Medium
201 Bitwise AND of Numbers Range 34% Medium
202 Happy Number 41% Easy
203 Remove Linked List Elements 33% Easy
204 Count Primes 26% Easy
205 Isomorphic Strings 34% Easy
206 Reverse Linked List 46% Easy
207 Course Schedule 33% Medium
208 Implement Trie (Prefix Tree) 30% Medium
209 Minimum Size Subarray Sum 31% Medium
210 Course Schedule II 29% Medium
211 Add and Search Word - Data structure design 24% Medium
212 Word Search II 24% Hard
213 House Robber II 34% Medium
214 Shortest Palindrome 24% Hard
215 Kth Largest Element in an Array 40% Medium
216 Combination Sum III 46% Medium
217 Contains Duplicate 46% Easy
218 The Skyline Problem 28% Hard
219 Contains Duplicate II 32% Easy
220 Contains Duplicate III 18% Medium
221 Maximal Square 29% Medium
223 Rectangle Area 33% Medium
224 Basic Calculator 28% Hard
225 Implement Stack using Queues 33% Easy
226 Invert Binary Tree 52% Easy
227 Basic Calculator II 29% Medium
228 Summary Ranges 31% Medium
229 Majority Element II 28% Medium
230 Kth Smallest Element in a BST 44% Medium
231 Power of Two 40% Easy
232 Implement Queue using Stacks 37% Easy
233 Number of Digit One 28% Hard
234 Palindrome Linked List 33% Easy
238 Product of Array Except Self 50% Medium
239 Sliding Window Maximum 33% Hard
240 Search a 2D Matrix II 38% Medium
241 Different Ways to Add Parentheses 45% Medium
242 Valid Anagram 47% Easy
257 Binary Tree Paths 40% Easy
258 Add Digits 51% Easy
260 Single Number III 52% Medium
263 Ugly Number 39% Easy
264 Ugly Number II 33% Medium
268 Missing Number 44% Easy
273 Integer to English Words 22% Hard
274 H-Index 33% Medium
275 H-Index II 34% Medium
279 Perfect Squares 37% Medium
282 Expression Add Operators 30% Hard
283 Move Zeroes 51% Easy
287 Find the Duplicate Number 43% Medium
289 Game of Life 37% Medium
290 Word Pattern 33% Easy
292 Nim Game 55% Easy
295 Find Median from Data Stream 28% Hard
299 Bulls and Cows 35% Medium
300 Longest Increasing Subsequence 38% Medium
301 Remove Invalid Parentheses 35% Hard
303 Range Sum Query - Immutable 31% Easy
304 Range Sum Query 2D - Immutable 26% Medium
306 Additive Number 27% Medium
307 Range Sum Query - Mutable 21% Medium
309 Best Time to Buy and Sell Stock with Cooldown 41% Medium
310 Minimum Height Trees 28% Medium
312 Burst Balloons 43% Hard
313 Super Ugly Number 38% Medium
315 Count of Smaller Numbers After Self 34% Hard
316 Remove Duplicate Letters 30% Hard
318 Maximum Product of Word Lengths 45% Medium
319 Bulb Switcher 42% Medium
321 Create Maximum Number 24% Hard
322 Coin Change 26% Medium
324 Wiggle Sort II 26% Medium
326 Power of Three 40% Easy
327 Count of Range Sum 30% Hard
328 Odd Even Linked List 44% Medium
329 Longest Increasing Path in a Matrix 37% Hard
330 Patching Array 32% Hard
331 Verify Preorder Serialization of a Binary Tree 36% Medium
332 Reconstruct Itinerary 29% Medium
334 Increasing Triplet Subsequence 40% Medium
335 Self Crossing 25% Hard
336 Palindrome Pairs 26% Hard
337 House Robber III 44% Medium
338 Counting Bits 61% Medium
342 Power of Four 38% Easy
343 Integer Break 46% Medium
344 Reverse String 59% Easy
345 Reverse Vowels of a String 38% Easy
347 Top K Frequent Elements 49% Medium
349 Intersection of Two Arrays 47% Easy
350 Intersection of Two Arrays II 44% Easy
352 Data Stream as Disjoint Intervals 40% Hard
354 Russian Doll Envelopes 32% Hard
355 Design Twitter 25% Medium
357 Count Numbers with Unique Digits 46% Medium
363 Max Sum of Rectangle No Larger Than K 33% Hard
365 Water and Jug Problem 27% Medium
367 Valid Perfect Square 38% Easy
368 Largest Divisible Subset 33% Medium
371 Sum of Two Integers 51% Easy
372 Super Pow 34% Medium
373 Find K Pairs with Smallest Sums 31% Medium
375 Guess Number Higher or Lower II 36% Medium
376 Wiggle Subsequence 36% Medium
377 Combination Sum IV 42% Medium
378 Kth Smallest Element in a Sorted Matrix 45% Medium
380 Insert Delete GetRandom O(1) 39% Medium
381 Insert Delete GetRandom O(1) - Duplicates allowed 29% Hard
382 Linked List Random Node 47% Medium
383 Ransom Note 47% Easy
384 Shuffle an Array 47% Medium
385 Mini Parser 30% Medium
387 First Unique Character in a String 47% Easy
388 Longest Absolute File Path 37% Medium
389 Find the Difference 51% Easy
390 Elimination Game 42% Medium
391 Perfect Rectangle 27% Hard
392 Is Subsequence 44% Medium
393 UTF-8 Validation 34% Medium
394 Decode String 41% Medium
395 Longest Substring with At Least K Repeating Characters 35% Medium
396 Rotate Function 33% Medium
397 Integer Replacement 30% Medium
398 Random Pick Index 44% Medium
399 Evaluate Division 41% Medium
400 Nth Digit 30% Easy
401 Binary Watch 44% Easy
402 Remove K Digits 26% Medium
403 Frog Jump 32% Hard
404 Sum of Left Leaves 47% Easy
405 Convert a Number to Hexadecimal 41% Easy
406 Queue Reconstruction by Height 56% Medium
407 Trapping Rain Water II 37% Hard
409 Longest Palindrome 45% Easy
410 Split Array Largest Sum 38% Hard
412 Fizz Buzz 58% Easy
413 Arithmetic Slices 54% Medium
414 Third Maximum Number 27% Easy
415 Add Strings 41% Easy
416 Partition Equal Subset Sum 39% Medium
417 Pacific Atlantic Water Flow 34% Medium
419 Battleships in a Board 62% Medium
420 Strong Password Checker 20% Hard
421 Maximum XOR of Two Numbers in an Array 47% Medium
423 Reconstruct Original Digits from English 44% Medium
424 Longest Repeating Character Replacement 42% Medium
432 All O`one Data Structure 28% Hard
434 Number of Segments in a String 36% Easy
435 Non-overlapping Intervals 41% Medium
436 Find Right Interval 41% Medium
437 Path Sum III 40% Easy
438 Find All Anagrams in a String 33% Easy
440 K-th Smallest in Lexicographical Order 25% Hard
441 Arranging Coins 36% Easy
442 Find All Duplicates in an Array 56% Medium
443 String Compression 36% Easy
445 Add Two Numbers II 45% Medium
446 Arithmetic Slices II - Subsequence 27% Hard
447 Number of Boomerangs 46% Easy
448 Find All Numbers Disappeared in an Array 51% Easy
450 Delete Node in a BST 37% Medium
451 Sort Characters By Frequency 51% Medium
452 Minimum Number of Arrows to Burst Balloons 44% Medium
453 Minimum Moves to Equal Array Elements 47% Easy
454 4Sum II 47% Medium
455 Assign Cookies 47% Easy
456 132 Pattern 28% Medium
459 Repeated Substring Pattern 38% Easy
460 LFU Cache 24% Hard
461 Hamming Distance 69% Easy
462 Minimum Moves to Equal Array Elements II 51% Medium
463 Island Perimeter 57% Easy
464 Can I Win 25% Medium
466 Count The Repetitions 27% Hard
467 Unique Substrings in Wraparound String 33% Medium
468 Validate IP Address 20% Medium
472 Concatenated Words 30% Hard
473 Matchsticks to Square 35% Medium
474 Ones and Zeroes 39% Medium
475 Heaters 29% Easy
476 Number Complement 60% Easy
477 Total Hamming Distance 47% Medium
479 Largest Palindrome Product 24% Easy
480 Sliding Window Median 31% Hard
481 Magical String 45% Medium
482 License Key Formatting 40% Easy
483 Smallest Good Base 33% Hard
485 Max Consecutive Ones 54% Easy
486 Predict the Winner 45% Medium
488 Zuma Game 37% Hard
491 Increasing Subsequences 39% Medium
492 Construct the Rectangle 48% Easy
493 Reverse Pairs 21% Hard
494 Target Sum 43% Medium
495 Teemo Attacking 51% Medium
496 Next Greater Element I 56% Easy
498 Diagonal Traverse 46% Medium
500 Keyboard Row 59% Easy
501 Find Mode in Binary Search Tree 37% Easy
502 IPO 36% Hard
503 Next Greater Element II 47% Medium
504 Base 7 44% Easy
506 Relative Ranks 46% Easy
507 Perfect Number 33% Easy
508 Most Frequent Subtree Sum 52% Medium
513 Find Bottom Left Tree Value 56% Medium
514 Freedom Trail 39% Hard
515 Find Largest Value in Each Tree Row 55% Medium
516 Longest Palindromic Subsequence 42% Medium
517 Super Washing Machines 36% Hard
520 Detect Capital 52% Easy
521 Longest Uncommon Subsequence I 55% Easy
522 Longest Uncommon Subsequence II 31% Medium
523 Continuous Subarray Sum 23% Medium
524 Longest Word in Dictionary through Deleting 43% Medium
525 Contiguous Array 41% Medium
526 Beautiful Arrangement 53% Medium
529 Minesweeper 49% Medium
530 Minimum Absolute Difference in BST 47% Easy
532 K-diff Pairs in an Array 28% Easy
537 Complex Number Multiplication 63% Medium
538 Convert BST to Greater Tree 49% Easy
539 Minimum Time Difference 46% Medium
540 Single Element in a Sorted Array 56% Medium
541 Reverse String II 43% Easy
542 01 Matrix 32% Medium
543 Diameter of Binary Tree 44% Easy
546 Remove Boxes 35% Hard
547 Friend Circles 49% Medium
551 Student Attendance Record I 44% Easy
552 Student Attendance Record II 31% Hard
553 Optimal Division 55% Medium
554 Brick Wall 46% Medium
556 Next Greater Element III 29% Medium
557 Reverse Words in a String III 59% Easy
560 Subarray Sum Equals K 40% Medium
561 Array Partition I 66% Easy
563 Binary Tree Tilt 47% Easy
564 Find the Closest Palindrome 17% Hard
565 Array Nesting 49% Medium
566 Reshape the Matrix 58% Easy
567 Permutation in String 36% Medium
572 Subtree of Another Tree 40% Easy
575 Distribute Candies 58% Easy
576 Out of Boundary Paths 30% Medium
581 Shortest Unsorted Continuous Subarray 29% Easy
583 Delete Operation for Two Strings 44% Medium
587 Erect the Fence 32% Hard
591 Tag Validator 30% Hard
592 Fraction Addition and Subtraction 45% Medium
593 Valid Square 40% Medium
594 Longest Harmonious Subsequence 41% Easy
598 Range Addition II 48% Easy
599 Minimum Index Sum of Two Lists 46% Easy
600 Non-negative Integers without Consecutive Ones 31% Hard
605 Can Place Flowers 30% Easy
606 Construct String from Binary Tree 49% Easy
609 Find Duplicate File in System 52% Medium
611 Valid Triangle Number 42% Medium
617 Merge Two Binary Trees 67% Easy
621 Task Scheduler 42% Medium
623 Add One Row to Tree 46% Medium
628 Maximum Product of Three Numbers 45% Easy
629 K Inverse Pairs Array 26% Hard
630 Course Schedule III 29% Hard
632 Smallest Range 42% Hard
633 Sum of Square Numbers 32% Easy
636 Exclusive Time of Functions 44% Medium
637 Average of Levels in Binary Tree 55% Easy
638 Shopping Offers 44% Medium
639 Decode Ways II 24% Hard
640 Solve the Equation 38% Medium
643 Maximum Average Subarray I 37% Easy
645 Set Mismatch 40% Easy
646 Maximum Length of Pair Chain 47% Medium
647 Palindromic Substrings 55% Medium
648 Replace Words 47% Medium
649 Dota2 Senate 36% Medium
650 2 Keys Keyboard 44% Medium
652 Find Duplicate Subtrees 37% Medium
653 Two Sum IV - Input is a BST 50% Easy
654 Maximum Binary Tree 69% Medium
655 Print Binary Tree 49% Medium
657 Judge Route Circle 68% Easy
658 Find K Closest Elements 35% Medium
659 Split Array into Consecutive Subsequences 36% Medium
661 Image Smoother 46% Easy
662 Maximum Width of Binary Tree 38% Medium
664 Strange Printer 33% Hard
665 Non-decreasing Array 20% Easy
667 Beautiful Arrangement II 51% Medium
668 Kth Smallest Number in Multiplication Table 38% Hard
669 Trim a Binary Search Tree 58% Easy
670 Maximum Swap 38% Medium
671 Second Minimum Node In a Binary Tree 41% Easy
672 Bulb Switcher II 48% Medium
673 Number of Longest Increasing Subsequence 31% Medium
674 Longest Continuous Increasing Subsequence 42% Easy
675 Cut Off Trees for Golf Event 27% Hard
676 Implement Magic Dictionary 49% Medium
677 Map Sum Pairs 52% Medium
678 Valid Parenthesis String 29% Medium
679 24 Game 38% Hard
680 Valid Palindrome II 32% Easy
682 Baseball Game 58% Easy
684 Redundant Connection 41% Medium
685 Redundant Connection II 28% Hard
686 Repeated String Match 34% Easy
687 Longest Univalue Path 33% Easy
688 Knight Probability in Chessboard 39% Medium
689 Maximum Sum of 3 Non-Overlapping Subarrays 41% Hard
691 Stickers to Spell Word 34% Hard
692 Top K Frequent Words 41% Medium
693 Binary Number with Alternating Bits 55% Easy
695 Max Area of Island 52% Easy
696 Count Binary Substrings 51% Easy
697 Degree of an Array 46% Easy
698 Partition to K Equal Sum Subsets 37% Medium
699 Falling Squares 37% Hard
712 Minimum ASCII Delete Sum for Two Strings 51% Medium
713 Subarray Product Less Than K 33% Medium
714 Best Time to Buy and Sell Stock with Transaction Fee 43% Medium
715 Range Module 30% Hard
717 1-bit and 2-bit Characters 49% Easy
718 Maximum Length of Repeated Subarray 40% Medium
719 Find K-th Smallest Pair Distance 26% Hard
720 Longest Word in Dictionary 41% Easy
721 Accounts Merge 31% Medium
722 Remove Comments 26% Medium
724 Find Pivot Index 40% Easy
725 Split Linked List in Parts 48% Medium
726 Number of Atoms 44% Hard
728 Self Dividing Numbers 67% Easy
729 My Calendar I 40% Medium
730 Count Different Palindromic Subsequences 34% Hard
731 My Calendar II 36% Medium
732 My Calendar III 54% Hard
733 Flood Fill 48% Easy
735 Asteroid Collision 37% Medium
736 Parse Lisp Expression 42% Hard
738 Monotone Increasing Digits 41% Medium
739 Daily Temperatures 53% Medium
740 Delete and Earn 42% Medium
741 Cherry Pickup 22% Hard
744 Network Delay Time 33% Medium
745 Find Smallest Letter Greater Than Target 47% Easy
746 Prefix and Suffix Search 23% Hard
747 Min Cost Climbing Stairs 45% Easy
748 Largest Number At Least Twice of Others 46% Easy
749 Shortest Completing Word 54% Medium
750 Contain Virus 39% Hard
753 Open the Lock 37% Medium
754 Cracking the Safe 39% Hard
755 Reach a Number 23% Medium
756 Pour Water 33% Medium
757 Pyramid Transition Matrix 40% Medium
759 Set Intersection Size At Least Two 33% Hard

以下免费的算法题,暂时不能使用 Go 解答

helper

helper 会处理大部分琐碎的工作。

notes

notes 记录了我答题过程中,对知识点的总结。

kit

针对 LeetCode 中经常出现的以下数据结构,在 kit 中进行了定义,并添加了与 []int 相互转换的函数。利用 Go 1.9 新添加的 type alias 功能,易于添加单元测试。

Directories

Path Synopsis
Algorithms

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL