# LeetCode **Repository Path**: Heconnor/LeetCode ## Basic Information - **Project Name**: LeetCode - **Description**: No description available - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-05-13 - **Last Updated**: 2025-06-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: Algorithm ## README
  [](LICENSE) ## Table of Contents - [Table of Contents](#table-of-contents) - [Description](#description) - [Category](#category) - [Custom](#custom) - [Algorithms-TODO](#algorithms-todo) - [Contributors](#contributors) ## Description Solutions for the problem in [LeetCode](https://leetcode.com/problemset/all/) ## Category ### Custom > 按照知识点分类整合[lib](./lib/README.md) ### Topics - Array - Binary Search - Bit Manipulation - Combinatorics - Dynamic Programming *** - Enumeration - Greedy - Hash Table - Math - Matrix - Monotonic Stack - Number Theory - Recursive / Recursion - Sliding Window - Stack - String - Two Pointers ### Algorithms-TODO - [x] [0001. Two Sum](./algorithms/TwoSum.py) - [x] [0002. Add Two Numbers](./algorithms/AddTwoNumbers.py) - [x] [0003. Longest Substring Without Repeating Characters](./algorithms/LongestSubstring.py) - [x] [0004. Median of Two Sorted Arrays](./algorithms/MedianOfTwoArrays.py) - [x] [0005. Longest Palindromic Substring](./algorithms/LongestPalindromicSubsting.py) - [x] [0006. ZigZag Conversion](./algorithms/ZigZagConversion.py) - [x] [0007. Reverse Integer](./algorithms/ReverseInteger.py) - [x] [0008. String to Integer (atoi)](./algorithms/StringToInteger.py) - [x] [0009. Palindrome Number](./algorithms/PalindromeNumber.py) - [x] [0010. Regular Expression Matching](./algorithms/RegularExpressionMatching.py) - [x] [0011. Container With Most Water](./algorithms/ContainerWithMostWater.py) - [x] [0012. Integer to Roman](./algorithms/IntegerToRoman.py) - [x] [0013. Roman to Integer](./algorithms/RomanToInteger.py) - [x] [0014. Longest Common Prefix](./algorithms/LongestCommonPrefix.py) - [x] [0015. 3Sum](./algorithms/3Sum.py) - [x] [0016. 3Sum Closest](./algorithms/3SumClosest.py) - [x] [0017. Letter Combinations of a Phone Number](./algorithms/LetterCombinationsPhoneNumber.py) - [x] [0018. 4Sum](./algorithms/4Sum.py) - [x] [0019. Remove Nth Node From End of List](./algorithms/RemoveNthNodeEndList.py) - [x] [0020. Valid Parentheses](./algorithms/ValidParentheses.py) - [x] [0021. Merge Two Sorted Lists](./algorithms/MergeTwoSortedLists.py) - [x] [0022. Generate Parentheses](./algorithms/GenerateParentheses.py) - [x] [0023. Merge k Sorted Lists](./algorithms/MergeKSortedLists.py) - [x] [0024. Swap Nodes in Pairs](./algorithms/SwapNodesPairs.py) - [x] [0025. Reverse Nodes in k-Group](./algorithms/ReverseNodesKGroup.py) - [x] [0026. Remove Duplicates from Sorted Array](./algorithms/RemoveDuplicatesSortedArr.py) - [x] [0027. Remove Element](./algorithms/RemoveElement.py) - [x] [0028. Implement strStr()](./algorithms/ImplementStr.py) - [x] [0029. Divide Two Integers](./algorithms/DivideTwoIntegers.py) - [x] [0030. Substring with Concatenation of All Words](./algorithms/SubstringConcatenationAllWords.py) - [x] [0031. Next Permutation](./algorithms/NextPermutation.py) - [x] [0032. Longest Valid Parentheses](./algorithms/LongestValidParentheses.py) - [x] [0033. Search in Rotated Sorted Array](./algorithms/SearchArrayRotated.py) - [x] [0034. Find First and Last Position of Element in Sorted Array](./algorithms/FindFLPosArraySorted.py) - [x] [0035. Search Insert Position](./algorithms/SearchInsertPos.py) - [x] [0036. Valid Sudoku](./algorithms/ValidSudoku.py) - [x] [0037. Sudoku Solver](./algorithms/SudokuSolver.py) - [x] [0038. Count and Say](./algorithms/CountSay.py) - [x] [0039. Combination Sum](./algorithms/CombinationSum.py) - [x] [0040. Combination Sum II](./algorithms/CombinationSum2.py) - [x] [0041. First Missing Positive](./algorithms/FirstMissingPositive.py) - [x] [0042. Trapping Rain Water](./algorithms/TrappingRainWater.py) - [x] [0043. Multiply Strings](./algorithms/MultiplyStrings.py) - [x] [0044. Wildcard Matching](./algorithms/WildcardMatching.py) - [x] [0045. Jump Game II](./algorithms/JumpGame2.py) - [x] [0046. Permutations](./algorithms/Permutations.py) - [x] [0047. Permutations II](./algorithms/Permutations.py) - [x] [0048. Rotate Image](./algorithms/RotateImage.py) - [x] [0049. Group Anagrams](./algorithms/GroupAnagrams.py) - [x] [0050. Pow(x, n)](./algorithms/Pow_xn.py) - [x] [0051. N-Queens](./algorithms/NQueens.py) - [x] [0052. N-Queens II](./algorithms/NQueens.py) - [x] [0053. Maximum Subarray](./algorithms/MaximumSubarray.py) - [x] [0054. Spiral Matrix](./algorithms/SpiralMatrix.py) - [x] [0055. Jump Game](./algorithms/JumpGame.py) - [x] [0056. Merge Intervals](./algorithms/MergeIntervals.py) - [x] [0057. Insert Interval](./algorithms/InsertInterval.ipynb) - [x] [0058. Length of Last Word](./algorithms/LengthLastWord.ipynb) - [x] [0059. Spiral Matrix II](./algorithms/SpiralMatrix2.ipynb) - [x] [0060. Permutation Sequence](./algorithms/PermutationSequence.ipynb) - [x] [0061. Rotate List](./algorithms/RotateList.ipynb) - [x] [0062. Unique Paths](./algorithms/UniquePaths.ipynb) - [x] [0063. Unique Paths II](./algorithms/UniquePaths.ipynb) - [x] [0064. Minimum Path Sum](./algorithms/MinimumPathSum.py) - [x] [0065. Valid Number](./algorithms/ValidNumber.py) - [x] [0066. Plus One](./algorithms/PlusOne.py) - [x] [0067. Add Binary](./algorithms/AddBinary.py) - [x] [0068. Text Justification](./algorithms/TextJustification.py) - [x] [0069. Sqrt(x)](./algorithms/xSqrt.py) - [x] [0070. Climbing Stairs](./algorithms/ClimbingStairs.py) - [x] [0071. Simplify Path](./algorithms/SimplifyPath.py) - [x] [0072. Edit Distance](./algorithms/EditDistance.py) - [x] [0073. Set Matrix Zeroes](./algorithms/SetMatrixZeros.py) - [x] [0074. Search a 2D Matrix](./algorithms/Search2DMatrix.py) - [x] [0075. Sort Colors](./algorithms/SortColors.py) - [x] [0076. Minimum Window Substring](./algorithms/MinimumWindowSubstring.py) - [x] [0077. Combinations](./algorithms/Combinations.py) - [x] [0078. Subsets](./algorithms/Subsets.py) - [x] [0079. Word Search](./algorithms/WordSearch.py) - [x] [0080. Remove Duplicates from Sorted Array II](./algorithms/RemoveDuplicatesSortedArr2.py) - [x] [0081. Search in Rotated Sorted Array II](./algorithms/SearchArrayRotated2.py) - [x] [0082. Remove Duplicates from Sorted List II](./algorithms/RemoveDuplicatesSortedList2.py) - [x] [0083. Remove Duplicates from Sorted List](./algorithms/RemoveDuplicatesSortedList.py) - [x] [0084. Largest Rectangle in Histogram](./algorithms/LargestRectangleHistogram.ipynb) - [x] [0085. Maximal Rectangle](./algorithms/MaximalRectangle.py) - [x] [0086. Partition List](./algorithms/PartitionList.py) - [x] [0087. Scramble String](./algorithms/ScrambleString.py) - [x] [0088. Merge Sorted Array](./algorithms/MergeSortedArray.py) - [x] [0089. Gray Code](./algorithms/GrayCode.py) - [x] [0090. Subsets II](./algorithms/Subsets2.py) - [x] [0091. Decode Ways](./algorithms/DecodeWays.py) - [x] [0092. Reverse Linked List II](./algorithms/ReverseLinkedList2.py) - [ ] [0093. Restore IP Addresses] - [x] [0094. Binary Tree Inorder Traversal](./algorithms/BinaryTreeInorderTraversal.py) - [ ] [0095. Unique Binary Search Trees II] - [x] [0096. Unique Binary Search Trees](./algorithms/UniqueBinarySearchTrees.py) - [ ] ... - [x] [0104. Maximum Depth of Binary Tree](./algorithms/MaximumDepthBinaryTree.py) - [ ] [0105. Construct Binary Tree from Preorder and Inorder Traversal] - [x] [0106. Construct Binary Tree from Inorder and Postorder Traversal](./algorithms/ConstructBinaryTreeInorderPostorderTraversal.py) - [x] [0107. Binary Tree Level Order Traversal II](./algorithms/BinaryTreeLevelOrderTraversal2.py) - [x] [0108. Convert Sorted Array to Binary Search Tree](./algorithms/ConvertSortedArray2BinarySearchTree.py) - [ ] ... - [x] [0112. Path Sum](./algorithms/PathSum.py) - [ ] ... - [x] [0116. Populating Next Right Pointers in Each Node](./algorithms/PopulatingNextRightPointersEachNode.py) - [x] [0117. Populating Next Right Pointers in Each Node II](./algorithms/PopulatingNextRightPointersNode2.ipynb) - [x] [0118. Pascal's Triangle](./algorithms/PascalTriangle.py) - [ ] ... - [x] [0120. Triangle](./algorithms/Triangle.py) - [ ] ... - [x] [0122. Best Time to Buy and Sell Stock II](./algorithms/BestTimeBuySellStock2.py) - [ ] ... - [x] [0124. Binary Tree Maximum Path Sum](./algorithms/BinaryTreeMaximumPathSum.ipynb) - [x] [0125. Valid Palindrome](./algorithms/ValidPalindrome.py) - [x] [0126. Word Ladder II](./algorithms/WorldLadder2.py) - [x] [0127. Word Ladder](./algorithms/WorldLadder.py) - [x] [0128. Longest Consecutive Sequence](./algorithms/LongestConsecutiveSequence.py) - [x] [0129. Sum Root to Leaf Numbers](./algorithms/SumRootToLeafNumbers.py) - [x] [0130. Surrounded Regions](./algorithms/SurroundedRegions.py) - [ ] ... - [x] [0134. Gas Station](./algorithms/GasStation.py) - [ ] ... - [x] [0139. Word Break](./algorithms/WordBreak.py) - [x] [0140. Word Break II](./algorithms/WordBreak2.py) - [x] [0141. Linked List Cycle](./algorithms/LinkedListCycle.py) - [x] [0142. Linked List Cycle II](./algorithms/LinkedListCycle2.py) - [ ] [0143. Reorder List] - [x] [0144. Binary Tree Preorder Traversal](./algorithms/BinaryTreePreorderTraversal.py) - [x] [0145. Binary Tree Postorder Traversal](./algorithms/BinaryTreePostorderTraversal.ipynb) - [ ] [0146. LRU Cache] - [x] [0147. Insertion Sort List](./algorithms/InsertionSortList.py) - [x] [0148. Sort List](./algorithms/SortList.py) - [ ] ... - [x] [0164. Maximum Gap](./algorithms/MaximumGap.py) - [ ] ... - [x] [0174. Dungeon Game](./algorithms/DungeonGame.py) - [ ] ... - [x] [0204. Count Primes](./algorithms/CountPrimes.py) - [ ] ... - [x] [0207. Course Schedule](./algorithms/CourseSchedule.py) - [x] [0208. Implement Trie (Prefix Tree)](./algorithms/ImplementTrie.py) - [x] [0209. Minimum Size Subarray Sum](./algorithms/MinimumSizeSubarraySum.py) - [ ] ... - [x] [0214. Shortest Palindrome](./algorithms/ShortestPalindrome.py) - [x] [0215. Kth Largest Element in an Array](./algorithms/KthLargestElementInArray.py) - [x] [0216. Combination Sum III](./algorithms/CombinationSum3.py) - [ ] ... - [x] [0222. Count Complete Tree Nodes](./algorithms/CountCompleteTreeNodes.py) - [ ] ... - [x] [0226. Invert Binary Tree](./algorithms/InvertBinaryTree.py) - [ ] ... - [x] [0234. Palindrome Linked List](./algorithms/PalindromeLinkedList.py) - [x] [0235. Lowest Common Ancestor of a Binary Search Tree](./algorithms/LowestCommonAncestorBinarySearchTree.ipynb) - [ ] ... - [x] [0238. Product of Array Except Self](./algorithms/ProductArrayExceptSelf.py) - [ ] ... - [x] [0242. Valid Anagram](./algorithms/ValidAnagram.py) - [ ] ... - [x] [0257. Binary Tree Paths](./algorithms/BinaryTreePaths.py) - [ ] ... - [x] [0309. Best Time to Buy and Sell Stock with Cooldown](./algorithms/BestTime2BuySellStockCooldown.py) - [ ] ... - [x] [0312. Burst Balloons](./algorithms/BurstBalloons.py) - [ ] ... - [x] [0321. Create Maximum Number](./algorithms/CreateMaximumNumber.py) - [ ] ... - [x] [0327. Count of Range Sum](./algorithms/CountRangeSum.py) - [x] [0328. Odd Even Linked List](./algorithms/OddEvenLinkedList.py) - [x] [0329. Longest Increasing Path in a Matrix](./algorithms/LongestIncreasingPathMatrix.py) - [ ] ... - [x] [0336. Palindrome Pairs](./algorithms/PalindromePairs.py) - [x] [0337. House Robber III](./algorithms/HouseRobber3.py) - [ ] ... - [x] [0343. Integer Break](./algorithms/IntegerBreak.py) - [x] [0344. Reverse String](./algorithms/ReverseString.py) - [ ] ... - [x] [0347. Top K Frequent Elements](./algorithms/TopKFrequentElements.py) - [ ] ... - [x] [0349. Intersection of Two Arrays](./algorithms/IntersectionTwoArrays.py) - [x] [0350. Intersection of Two Arrays II](./algorithms/IntersectionTwoArrays2.py) - [ ] ... - [x] [0378. Kth Smallest Element in a Sorted Matrix](./algorithms/KthSmallestElementInSortedMatrix.py) - [ ] ... - [x] [0381. Insert Delete GetRandom O(1) - Duplicates allowed](./algorithms/InsertDeleteGetRandom.py) - [ ] ... - [x] [0402. Remove K Digits](./algorithms/RemoveKDigits.py) - [ ] ... - [x] [0404. Sum of Left Leaves](./algorithms/SumLeftLeaves.py) - [ ] ... - [x] [0406. Queue Reconstruction by Height](./algorithms/QueueReconstructionHeight.py) - [ ] ... - [x] [0410. Split Array Largest Sum](./algorithms/SplitArrayLargestSum.py) - [ ] ... - [x] [0415. Add Strings](./algorithms/AddStrings.py) - [x] [0416. Partition Equal Subset Sum](./algorithms/PartitionEqualSubsetSum.py) - [ ] ... - [x] [0452. Minimum Number of Arrows to Burst Balloons](./algorithms/MinimumNumberArrowsBurstBalloons.py) - [ ] ... - [x] [0454. 4Sum II](./algorithms/4Sum2.py) - [ ] ... - [x] [0463. Island Perimeter](./algorithms/IslandPerimeter.py) - [ ] ... - [x] [0486. Predict the Winner](./algorithms/PredictWinner.py) - [ ] ... - [x] [0493. Reverse Pairs](./algorithms/ReversePairs.py) - [ ] ... - [x] [0501. Find Mode in Binary Search Tree](./algorithms/FindModeBinarySearchTree.py) - [ ] ... - [x] [0514. Freedom Trail](./algorithms/FreedomTrail.py) - [ ] ... - [x] [0529. Minesweeper](./algorithms/Minesweeper.ipynb) - [x] [0530. Minimum Absolute Difference in BST](./algorithms/MinimumAbsoluteDifferenceBST.py) - [ ] ... - [x] [0538. Convert BST to Greater Tree](./algorithms/ConvertBST2GreaterTree.py) - [ ] ... - [x] [0557. Reverse Words in a String III](./algorithms/ReverseWordsString3.py) - [ ] ... - [x] [0564. Find the Closest Palindrome](./algorithms/FindClosestPalindrome.py) - [ ] ... - [x] [0617. Merge Two Binary Trees](./algorithms/MergeTwoBinaryTrees.py) - [ ] ... - [x] [0621. Task Scheduler](./algorithms/TaskScheduler.py) - [ ] ... - [x] [0637. Average of Levels in Binary Tree](./algorithms/AverageLevelsBinaryTree.py) - [ ] ... - [x] [0647. Palindromic Substrings](./algorithms/PalindromicSubstrings.py) - [ ] ... - [x] [0649. Dota2 Senate](./algorithms/Data2Senate.py) - [ ] ... - [x] [0657. Robot Return to Origin](./algorithms/RobotReturnOrigin.py) - [ ] ... - [x] [0659. Split Array into Consecutive Subsequences](./algorithms/SplitArrayConsecutiveSubseq.py) - [ ] ... - [x] [0679. 24 Game](./algorithms/24Game.py) - [ ] ... - [x] [0685. Redundant Connection II](./algorithms/RedundantConnection2.py) - [ ] ... - [x] [0696. Count Binary Substrings](./algorithms/CountBinarySubstrings.py) - [ ] ... - [x] [0701. Insert into a Binary Search Tree](./algorithms/InsertBinarySearchTree.py) - [ ] ... - [x] [0718. Maximum Length of Repeated Subarray](./algorithms/MaximumLengthofRepeatedSubarray.py) - [ ] ... - [x] [0733. Flood Fill](./algorithms/FloodFill.py) - [ ] ... - [x] [0738. Monotone Increasing Digits](./algorithms/MonotoneIncreasingDigits.py) - [x] [0739. Daily Temperatures](./algorithms/DailyTemperatures.py) - [ ] ... - [x] [0763. Partition Labels](./algorithms/PartitionLabels.py) - [ ] ... - [x] [0767. Reorganize String](./algorithms/ReorganizeString.py) - [ ] ... - [x] [0771. Jewels and Stones](./algorithms/JewlesStones.py) - [ ] ... - [x] [0834. Sum of Distances in Tree](./algorithms/SumDistanceTree.py) - [ ] ... - [x] [0837. New 21 Game](./algorithms/New21Game.py) - [ ] ... - [x] [0842. Split Array into Fibonacci Sequence](./algorithms/SplitArrayFibonacciSequence.py) - [ ] ... - [x] [0845. Longest Mountain in Array](./algorithms/LongestMountainArray.py) - [ ] ... - [x] [0860. Lemonade Change](./algorithms/LemonadeChange.py) - [x] [0861. Score After Flipping Matrix](./algorithms/ScoreAfterFlippingMatrix.py) - [ ] ... - [x] [0922. Sort Array By Parity II](./algorithms/SortArrayParity2.py) - [ ] ... - [x] [0925. Long Pressed Name](./algorithms/LongPressedName.py) - [ ] ... - [x] [0968. Binary Tree Cameras](./algorithms/BinaryTreeCameras.py) - [ ] ... - [x] [0973. K Closest Points to Origin](./algorithms/KClosestPointsOrigin.py) - [ ] ... - [x] [0976. Largest Perimeter Triangle](./algorithms/LargestPerimeterTriangle.py) - [ ] ... - [x] [0990. Satisfiability of Equality Equations](./algorithms/SatisfiabilityEqualityEquations.py) - [ ] ... - [x] [1002. Find Common Characters](./algorithms/FindCommonCharacters.py) - [ ] ... - [x] [1014. Best Sightseeing Pair](./algorithms/BestSightseeingPair.py) - [ ] ... - [x] [1024. Video Stitching](./algorithms/VideoStitching.py) - [ ] ... - [x] [1028. Recover a Tree From Preorder Traversal](./algorithms/RecoverTreePreorderTraversal.py) - [ ] ... - [x] [1122. Relative Sort Array](./algorithms/RelativeSortArray.py) - [ ] ... - [x] [1207. Unique Number of Occurrences](./algorithms/UniqueNumberOccurrences.py) - [ ] ... - [x] [1030. Matrix Cells in Distance Order](./algorithms/MatrixCellDistanceOrder.py) - [ ] ... - [ ] [1351. Count Negative Numbers in a Sorted Matrix](./algorithms/CountNegativeNumbersInSortedMatrix.py) - [ ] ... - [x] [1356. Sort Integers by The Number of 1 Bits](./algorithms/SortIntegersByNumber1Bits.py) - [ ] ... - [x] [1370. Increasing Decreasing String](./algorithms/IncreasingDecreasingString.py) - [ ] ... - [x] [1431. Kids With the Greatest Number of Candies](./algorithms/KidsWithGreatestNumberOfCandies.py) - [ ] ... - [x] [1521. 剑指 Offer 09. 用两个栈实现队列](./algorithms/LCOF.py) - [ ] ... - [x] [1585. 剑指 Offer 64. 求1+2+…+n](./algorithms/SumOfFirstNitems.py) - [ ] ... - [x] [1591. Remove Duplicate Node LCCI](./algorithms/RemoveDuplicateNodeLCCI.py) - [ ] ... - [x] [1604. 剑指 Offer 20. 表示数值的字符串](./algorithms/ValidNumber.py) - [ ] ... - [x] [1621. 顺时针打印矩阵](./algorithms/SpiralMatrix.py) - [ ] ... - [x] [1644. 把数字翻译成字符串](./algorithms/TranslateNumToStr.py) - [ ] ... - [x] [1658. Pattern Matching LCCI](./algorithms/PatternMatchingLCCI.py) - [ ] ... - [x] [1666. 面试题 16.11. Diving Board LCCI](./algorithms/DivingBoard.py) - [ ] ... - [x] [1689. 面试题 08.03. Magic Index LCCI](./algorithms/MagicIndex.py) - [x] [1690. 面试题 08.04. Power Set LCCI](./algorithms/PowerSet.py) - [x] [1691. 面试题 17.13. Re-Space LCCI](./algorithms/ReSpace.py) - [ ] ... - [x] [2217. Find Palindrome With Fixed Length](./algorithms/FindPalindromeWithFixedLength.py) - [ ] ... - [x] [2396. Strictly Palindromic Number](./algorithms/StrictlyPalindromicNumber.py) - [ ] ... - [x] [2401. Longest Nice Subarray](./algorithms/LongestNiceSubarray.py) - [ ] ... - [x] [2843. Count Symmetric Integers](./algorithms/CountSymmetricIntegers.py) - [ ] ... - [x] [3260. Find the Largest Palindrome Divisible by K](./algorithms/FindLargestPalindromeDivisibleK.py) - [ ] ... - [x] [3272. Find the Count of Good Integers](./algorithms/FindCountGoodIntegers.py) - [ ] ... ## Contributors [](https://gitee.com/Heconnor)