Skip to content

This repository contains the solutions and explanations to the algorithm problems on LeetCode. Only medium or above are included. All are written in C++/Python and implemented by myself. The problems attempted multiple times are labelled with hyperlinks.

Notifications You must be signed in to change notification settings

777shinichi/LeetCode-1

Repository files navigation

LeetCode难题代码和算法要点分析

目前分类目录:

003.Longest Substring Without Repeating Character (E+)
011.Container-With-Most-Water (M+)
015.3Sum (M)
016.3Sum-Closet (M)
018.4Sum (M)
259.3Sum-Smaller (M+)
030.Substring-with-Concatenation-of-All-Words (H)
075.Sort-Colors (M+)
076.Minimum Window Substring (M+)
026.Remove Duplicates from Sorted Array (H-)
080.Remove Duplicates from Sorted Array II (H)
209.Minimum-Size-Subarray-Sum (M)
088.Merge Sorted Array (M)
283.Move-Zeroes (M)
141.Linked-List-Cycle (E+)
340.Longest-Substring-with-At-Most-K-Distinct-Characters (H)
532.K-diff-Pairs-in-an-Array (H-)
360.Sort-Transformed-Array (M)
159.Longest-Substring-with-At-Most-Two-Distinct-Characters(H-)
611.Valid-Triangle-Number (M+)

154.Find Minimum in Rotated Sorted Array II (H-)    
033.Search in Rotated Sorted Array (M)
081.Search-in-Rotated-Sorted-Array-II (M)
034.Search-for-a-Range (M)
162.Find-Peak-Element (H-)
275.H-index II (H)
287.Find the Duplicate Number (H-)
302.Smallest-Rectangle-Enclosing-Black-Pixels (M+)
410.Split-Array-Largest-Sum (H)
475.Heaters (H-)
483.Smallest-Good-Base (H)
029.Divide-Two-Integers (M+)
668.Kth-Smallest-Number-in-Multiplication-Table (H-)

049.Group-Anagrams (M+)
149.Max Points on a Line (H)
166.Fraction-to-Recurring-Decimal (M)
170.Two-Sum-III-Data-structure-design (M)
392.Is-Subsequence (H-)
204.Count Primes (M)
274.H-Index (H)
325.Maximum-Size-Subarray-Sum-Equals-k (M)
363.Max-Sum-of-Rectangle-No-Larger-Than-K (H)
409.Longest-Palindrome (M)
447.Number-of-Boomerangs (E+)
438.Find-All-Anagrams-in-a-String (H-)
525.Contiguous-Array (M)
356.Line-Reflection (H-)
594.Longest-Harmonious-Subsequence (M+)
532.K-diff-Pairs-in-an-Array (E+)
352.Data-Stream-as-Disjoint-Intervals (H)
480.Sliding-Window-Median (H)

270.Closest-Binary-Search-Tree-Value (M+)
095.Unique-Binary-Search-Trees-II (H)
094.Binary Tree Inorder Traversal (H-)
144.Binary-Tree-Preorder-Traversal (M+)
145.Binary-Tree-Postorder-Traversal (H-)
110.Balanced-Binary-Tree (M+)
124.Binary-Tree-Maximum-Path-Sum (M+)
236.Lowest Common Ancestor of a Binary Tree (H)
297.Serialize-and-Deserialize-Binary-Tree (H-)
105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal (H-)
106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal (M+)
099.Recover-Binary-Search-Tree (H)
114.Flatten-Binary-Tree-to-Linked-List (M+)
098.Validate-Binary-Search-Tree (M)
117.Populating Next Right Pointers in Each Node II (H)
156.Binary-Tree-Upside-Down (H)
285.Inorder-Successor-in-BST (M)
298.Binary-Tree-Longest-Consecutive Sequence (M+)
450.Delete-Node-in-a-BST (H)
437.Path-Sum-III (H-)
255.Verify-Preorder-Sequence-in-Binary-Search-Tree (H)
449.Serialize-and-Deserialize-BST (H)
333.Largest-BST-Subtree (H)
543.Diameter-of-Binary-Tree (M+)
572.Subtree-of-Another-Tree (M)
549.Binary-Tree-Longest-Consecutive-Sequence-II (M)
173.Binary-Search-Tree-Iterator (M)
545.Boundary-of-Binary-Tree (H-)
272.Closest-Binary-Search-Tree-Value-II (M+)
310.Minimum-Height-Trees (H-)
331.Verify-Preorder-Serialization-of-a-Binary-Tree (H)
226.Invert-Binary-Tree (M)
655.Print-Binary-Tree (M+)
501.Find-Mode-in-Binary-Search-Tree (M+)
662.Maximum-Width-of-Binary-Tree (H-)

460.LFU Cache (H)
380.Insert-Delete-GetRandom-O(1) (H-)
381.Insert-Delete-GetRandom-O-1-Duplicates-allowed (H)
355.Design Twitter (H)
535.Encode-and-Decode-TinyURL (M)
631.Design-Excel-Sum-Formula (H)
146.LRU-Cache (H-)
642.Design-Search-Autocomplete-System (M+)

536.Construct-Binary-Tree-from-String (M)
155.Min-Stack (M)
225.Implement Stack using Queues (H-)
232.Implement-Queue-using-Stacks (H-)
255.Verify-Preorder-Sequence-in-Binary-Search-Tree (H)
341.Flatten-Nested-List-Iterator (M)
385.Mini-Parser (H)
173.Binary-Search-Tree-Iterator (M)
456.132-Pattern (H-)
084.Largest-Rectangle-in-Histogram (H)
085.Maximal-Rectangle (H-)
402.Remove-K-Digits (H-)
173.Binary-Search-Tree-Iterator (M)
316.Remove-Duplicate-Letters (H)
224.Basic-Calculator(H-)
439.Ternary-Expression-Parser (H-)
496.Next-Greater-Element-I (H-)
503.Next-Greater-Element-II (M+)
591.Tag-Validator (H)
221.Maximal-Square (H-)
636.Exclusive-Time-of-Functions (H-)

004.Median-of-Two-Sorted-Arrays (H)
358.Rearrange-String-k-Distance-Apart (H-)
378.Kth-Smallest-Element-in-a-Sorted-Matrix (M)
373.Find-K-Pairs-with-Smallest-Sums (H)
632.Smallest-Range (M)
642.Design-Search-Autocomplete-System (M+)
502.IPO (H-)
621.Task-Scheduler (M+)

051.N-Queens (H)
417.Pacific-Atlantic-Water-Flow (M)
200.Number-of-Islands (M)
133.Clone-Graph (M+)
410.Split-Array-Largest-Sum (H)
282.Expression-Add-Operators (H)
399.Evaluate-Division (H)
491.Increasing-Subsequences (M)
638.Shopping-Offers (H-)

133.Clone-Graph (M+)
200.Number-of-Islands (H-)
407.Trapping-Rain-Water-II
378.Kth-Smallest-Element-in-a-Sorted-Matrix (H)
310.Minimum-Height-Trees (H)
637.Average-of-Levels-in-Binary-Tree (M)

208.Implement-Trie--Prefix-Tree (M+)
211.Add-and-Search-Word (H-)
421.Maximum XOR of Two Numbers in an Array (H)
648.Replace-Words (H)

084.Largest-Rectangle-in-Histogram
085.Maximal-Rectangle
221.Maximal-Square
300.Longest Increasing Subsequence
354.Russian-Doll-Envelopes
316.Remove Duplicate Letters
358.Rearrange-String-k-Distance-Apart
045.Jump-Game-II (H)
229.Majority-Element-II (H)
659.Split-Array-into-Consecutive-Subsequences (H-)
484.Find-Permutation (H)
386.Lexicographical-Numbers (H)
452.Minimum-Number-of-Arrows-to-Burst-Balloons (M+)
624.Maximum-Distance-in-Arrays (M)
630.Course-Schedule-III (H)
672.Bulb-Switcher-II (H)
665.Non-decreasing-Array (H-)

061.Rotate-List
086.Partition-List (M)
142.Linked List Cycle II (M+)
109.Convert-Sorted-List-to-Binary-Search-Tree (M)
092.Reverse Linked List II (H)

487.Max-Consecutive-Ones-II
410.Split-Array-Largest-Sum (H)
376.Wiggle-Subsequence (H)
322.Coin-Change (M)
091.Decode-Ways (M)
639.Decode-Ways-II (H)
629.K-Inverse-Pairs-Array (H)
634.Find the Derangement-of-An-Array (H)
221.Maximal-Square (H-)
644.Maximum-Average-Subarray-II (H)
576.Out-of-Boundary-Paths (H)
600.Non-negative-Integers-without-Consecutive-Ones (H)
115.Distinct-Subsequences (H)
656.Coin-Path (H-)
152.Maximum-Product-Subarray (M+)
474.Ones-and-Zeroes (H-)
664.Strange-Printer (H)
651.4-Keys-Keyboard (M+)
097.Interleaving-String (H-)
072.Edit-Distance (H-)

136.Single-Number (M)
371.Sum-of-Two-Integers (H)
318.Maximum-Product-of-Word-Lengths (M+)
342.Power-of-Four (H)

Divide and Conquer

315.Count-of-Smaller-Numbers-After-Self

408.Valid-Word-Abbreviation (M)
527.Word-Abbreviation (M+)
336.Palindrome-Pairs (H-)
647.Palindromic-Substrings (M+)
556.Next Greater Element III (H-)
028.Implement-strStr (H)
616.Add-Bold-Tag-in-String (M)
467.Unique-Substrings-in-Wraparound-String (H-)
564.Find-the-Closest-Palindrome (H)

057.Insert-Interval (H)
164.Maximum-Gap (H)
581.shortest-unsorted-continuous-subarray (M+)
041.First-Missing-Positive (H)
442.Find-All-Duplicates-in-an-Array (M+)

042.Trapping-Rain-Water (M+)
240.Search a 2D Matrix II (M)
311.Sparse-Matrix-Multiplication (M)
307.Range-Sum-Query-Mutable (H)
593.Valid-Square (H)
060.Permutation-Sequence (H)
168.Excel-Sheet-Column-Title (H)
453.Minimum-Moves-to-Equal-Array-Elements (M)

About

This repository contains the solutions and explanations to the algorithm problems on LeetCode. Only medium or above are included. All are written in C++/Python and implemented by myself. The problems attempted multiple times are labelled with hyperlinks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 96.8%
  • Python 3.2%