# LeetCode **Repository Path**: hanlei-leishen/leet-code ## Basic Information - **Project Name**: LeetCode - **Description**: 自己的刷题小仓库 - **Primary Language**: Go - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2021-11-01 - **Last Updated**: 2022-06-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README LeetCode ======== ### LeetCode Algorithm | # | Title | Solution | Difficulty | |---| ----- | -------- | ---------- | |1|[两数之和](https://leetcode-cn.com/problems/two-sum/)| [Go](./algorithms/go/two_sum.go/)|E| |2|[三数之和](https://leetcode-cn.com/problems/3sum/submissions/)| [Go](./algorithms/go/three_nums.go/)|M| |3|[四数之和](https://leetcode-cn.com/problems/4sum/submissions/)| [Go](./algorithms/go/f_sum.go/)|M| |4|[二叉树深度](https://leetcode-cn.com/problems/er-cha-shu-de-shen-du-lcof/submissions/)| [Go](./algorithms/go/er-cha-shu-de-shen-du-lcof.go)|E| |5|[二叉树翻转](https://leetcode-cn.com/problems/invert-binary-tree/submissions/)| [Go](./algorithms/go/invertTree.go)|E| |6|[平衡二叉树](https://leetcode-cn.com/problems/balanced-binary-tree/)| [Go](./algorithms/go/isBalanced.go)|E| |7|[重构二叉树](https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)| [Go](./algorithms/go/build.go)|M| |8|[镜像二叉树](https://leetcode-cn.com/problems/symmetric-tree/submissions/)| [Go](./algorithms/go/isSymmetric.go)|E| |9|[杨辉三角](https://leetcode-cn.com/problems/pascals-triangle/submissions/)| [Go](./algorithms/go/generate.go)|E| |10|[杨辉三角2](https://leetcode-cn.com/problems/pascals-triangle-ii/submissions/)| [Go](./algorithms/go/generate2.go)|E| |11|[数组拆分1](https://leetcode-cn.com/problems/array-partition-i/)| [Go](./algorithms/go/arrayPairSum.go)|E| |12|[BFS](https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-lcof/)| [Go](./algorithms/go/levelOrder.go)|E| |13|[BFS2](https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-ii-lcof/)| [Go](./algorithms/go/bfs2.go)|E| |14|[BFS3](https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-iii-lcof/submissions/)| [Go](./algorithms/go/levelOrder3.go)|E| |15|[重塑数组](https://leetcode-cn.com/problems/reshape-the-matrix/submissions/)| [Go](./algorithms/go/matrixReshape.go)|E| |16|[二叉树最近公共祖先](https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/submissions/)| [Go](./algorithms/go/lowestCommonAncestor.go)|M| |17|[二叉搜索树最近公共祖先](https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-search-tree/submissions/)| [Go](./algorithms/go/lowestCommonAncestor2.go)|M| |18|[二叉树的宽度](https://leetcode-cn.com/problems/diameter-of-binary-tree/)| [Go](./algorithms/go/adiameterOfBinaryTree.go)|E| |19|[二叉搜索树的后序遍历序列](https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/)| [Go](./algorithms/go/verifyPostorder.go)|M| |20|[合并二叉树](https://leetcode-cn.com/problems/merge-two-binary-trees/)| [Go](./algorithms/go/mergeTrees.go)|E| |21|[填充每个节点的下一个右侧节点指针](https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node/)| [Go](./algorithms/go/connect.go)|M| |22|[二叉搜索树中第K小的元素](https://leetcode-cn.com/problems/kth-smallest-element-in-a-bst/)| [Go](./algorithms/go/kthSmallest.go)|M| |23|[二叉搜索树变累加树](https://leetcode-cn.com/problems/convert-bst-to-greater-tree/submissions/)| [Go](./algorithms/go/convertBST.go)|M| |24|[颜色填充](https://leetcode-cn.com/problems/color-fill-lcci/)| [Go](./algorithms/go/floodFill.go)|E| |25|[实现 strStr()](https://leetcode-cn.com/problems/implement-strstr/)| [Go](./algorithms/go/strStr.go)|E| |26|[下降路径最小和](https://leetcode-cn.com/problems/minimum-falling-path-sum/)| [Go](./algorithms/go/minFallingPathSum.go)|M| |27|[最长回文串](https://leetcode-cn.com/problems/longest-palindromic-substring/submissions/)| [Go](./algorithms/go/longestPalindrome.go)|M| |28|[股票最佳收益](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/)| [Go](./algorithms/go/maxProfit.go)|E| |29|[股票最佳收益2](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/)| [Go](./algorithms/go/maxProfit2.go)|E| |30|[回文数](https://leetcode-cn.com/problems/palindrome-number/)| [Go](./algorithms/go/isPalindrome.go)|E| |31|[最大子数组和](https://leetcode-cn.com/problems/maximum-subarray/submissions/)| [Go](./algorithms/go/maxSubArray.go)|E| |32|[爬楼梯](https://leetcode-cn.com/problems/climbing-stairs/)| [Go](./algorithms/go/climbStairs.go)|E| |33|[两个数组的交集](https://leetcode-cn.com/problems/intersection-of-two-arrays/)| [Go](./algorithms/go/intersection.go)|E| |34|[整数翻转](https://leetcode-cn.com/problems/reverse-integer/)| [Go](./algorithms/go/reverse.go)|E| |35|[14. 最长公共前缀](https://leetcode-cn.com/problems/longest-common-prefix/)| [Go](./algorithms/go/longestCommonPrefix.go)|E| |36|[24. 反转链表](https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/)| [Go](./algorithms/go/reverseList.go)|E| |37|[21. 合并两个有序链表](https://leetcode-cn.com/problems/merge-two-sorted-lists/)| [Go](./algorithms/go/mergeTwoLists.go)|E| |38|[26. 删除排序数组中的重复项 ](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/)| [Go](./algorithms/go/removeDuplicates.go)|E| |39|[11. 盛最多水的容器](https://leetcode-cn.com/problems/container-with-most-water/)| [Go](./algorithms/go/maxArea.go)|| |40|[1047. 删除字符串中的所有相邻重复项](https://leetcode-cn.com/problems/remove-all-adjacent-duplicates-in-string/)| [Go](./algorithms/go/removeDuplicates2.go)|E| |41|[27. 移除元素](https://leetcode-cn.com/problems/remove-element/submissions/)| [Go](./algorithms/go/removeElement.go)|E| |42|[35. 搜索插入位置](https://leetcode-cn.com/problems/search-insert-position/)| [Go](./algorithms/go/searchInsert.go)|E| |43|[66. 加一](https://leetcode-cn.com/problems/plus-one/)| [Go](./algorithms/go/plusMOne.go)|E| |44|[38. 外观数列](https://leetcode-cn.com/problems/count-and-say/)| [Go](./algorithms/go/countAndSay.go)|E| |45|[58. 最后一个单词的长度](https://leetcode-cn.com/problems/length-of-last-word/)| [Go](./algorithms/go/lengthOfLastWord.go)|E| |46|[73. 矩阵置零](https://leetcode-cn.com/problems/set-matrix-zeroes/)| [Go](./algorithms/go/setZeroes.go)|M| |47|[191. 位1的个数](https://leetcode-cn.com/problems/number-of-1-bits/)| [Go](./algorithms/go/hammingWeight.go)|E| |48|[69. x 的平方根](https://leetcode-cn.com/problems/sqrtx/)| [Go](./algorithms/go/mySqrt.go)|E| |49|[82. 删除排序链表中的重复元素 II](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/)| [Go](./algorithms/go/deleteDuplicates.go)|| |50|[83. 删除排序链表中的重复元素](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/)| [Go](./algorithms/go/deleteDuplicatesE.go)|E| |51|[19. 删除链表的倒数第 N 个结点 ](https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/)| [Go](./algorithms/go/removeNthFromEnd.go)|M| |52|[169. 多数元素](https://leetcode-cn.com/problems/majority-element/)| [Go](./algorithms/go/majorityElement.go)|E| |53|[160. 相交链表](https://leetcode-cn.com/problems/intersection-of-two-linked-lists/)| [Go](./algorithms/go/getIntersectionNode.go)|E| |54|[203. 移除链表元素](https://leetcode-cn.com/problems/remove-linked-list-elements/)| [Go](./algorithms/go/removeElements.go)|E| |55|[剑指 Offer 22. 链表中倒数第k个节点](https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/)| [Go](./algorithms/go/getKthFromEnd.go)|E| |56|[剑指 Offer 18. 删除链表的节点](https://leetcode-cn.com/problems/shan-chu-lian-biao-de-jie-dian-lcof/)| [Go](./algorithms/go/deleteNode.go)|E| |57|[剑指 Offer 06. 从尾到头打印链表](https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/)| [Go](./algorithms/go/reversePrint.go)|E| |58|[1721. 交换链表中的节点](https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/)| [Go](./algorithms/go/swapNodes.go)|M| |59|[530. 二叉搜索树的最小绝对差](https://leetcode-cn.com/problems/minimum-absolute-difference-in-bst/)| [Go](./algorithms/go/getMinimumDifference.go)|| |60|[23. 合并K个升序链表](https://leetcode-cn.com/problems/merge-k-sorted-lists/)| [Go](./algorithms/go/mergeKLists.go)|H| |61|[面试题 04.02. 最小高度树](https://leetcode-cn.com/problems/minimum-height-tree-lcci/)| [Go](./algorithms/go/sortedArrayToBST.go)|E| |62|[面试题 01.08. 零矩阵](https://leetcode-cn.com/problems/zero-matrix-lcci/)| [Go](./algorithms/go/setZeroes2.go)|| |63|[46. 全排列](https://leetcode-cn.com/problems/permutations/)| [Go](./algorithms/go/permute.go)|M| |64|[24. 两两交换链表中的节点](https://leetcode-cn.com/problems/swap-nodes-in-pairs/)| [Go](./algorithms/go/swapPairs.go)|M| |65|[面试题 02.05. 链表求和](https://leetcode-cn.com/problems/sum-lists-lcci/)| [Go](./algorithms/go/addTwoNumbers.go)|M| |66|[206. 反转链表](https://leetcode-cn.com/problems/reverse-linked-list/)| [Go](./algorithms/go/reverseList2.go)|E| |67|[237. 删除链表中的节点](https://leetcode-cn.com/problems/delete-node-in-a-linked-list/)| [Go](./algorithms/go/deleteNode2.go)|E| |68|[面试题 02.04. 分割链表](https://leetcode-cn.com/problems/partition-list-lcci/)| [Go](./algorithms/go/partition.go)|| |69|[725. 分隔链表](https://leetcode-cn.com/problems/split-linked-list-in-parts/)| [Go](./algorithms/go/splitListToParts.go)|M| |70|[148. 排序链表](https://leetcode-cn.com/problems/sort-list/)| [Go](./algorithms/go/sortList.go)|M| |71|[61. 旋转链表](https://leetcode-cn.com/problems/rotate-list/)| [Go](./algorithms/go/rotateRight.go)|M| |72|[25. K 个一组翻转链表](https://leetcode-cn.com/problems/reverse-nodes-in-k-group/)| [Go](./algorithms/go/reverseKGroup.go)|H| |73|[92. 反转链表 II](https://leetcode-cn.com/problems/reverse-linked-list-ii/)| [Go](./algorithms/go/reverseBetween.go)|H| |74|[86. 分隔链表](https://leetcode-cn.com/problems/partition-list/)| [Go](./algorithms/go/partition2.go)|M| |75|[面试题 02.06. 回文链表](https://leetcode-cn.com/problems/palindrome-linked-list-lcci/)| [Go](./algorithms/go/isPalindrome2.go)|E| |76|[328. 奇偶链表](https://leetcode-cn.com/problems/odd-even-linked-list/)| [Go](./algorithms/go/oddEvenList.go)|M| |77|[1669. 合并两个链表](https://leetcode-cn.com/problems/merge-in-between-linked-lists/)| [Go](./algorithms/go/mergeInBetween.go)|M| |78|[面试题 02.08. 环路检测](https://leetcode-cn.com/problems/linked-list-cycle-lcci/)| [Go](./algorithms/go/detectCycle.go)|M| |79|[面试题 02.02. 返回倒数第 k 个节点](https://leetcode-cn.com/problems/kth-node-from-end-of-list-lcci/)| [Go](./algorithms/go/kthToLast2.go)|E| |80|[445. 两数相加 II](https://leetcode-cn.com/problems/add-two-numbers-ii/)| [Go](./algorithms/go/addTwoNumbers2.go)|M| |81|[1290. 二进制链表转整数](https://leetcode-cn.com/problems/convert-binary-number-in-a-linked-list-to-integer/)| [Go](./algorithms/go/addTwoNumbers3.go)|E| |82|[1171. 从链表中删去总和值为零的连续节点](https://leetcode-cn.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/)| [Go](./algorithms/go/removeZeroSumSublists.go)|M| |83|[1367. 二叉树中的列表](https://leetcode-cn.com/problems/linked-list-in-binary-tree/)| [Go](./algorithms/go/isSubPath.go)|M| |84|[704. 二分查找](https://leetcode-cn.com/problems/binary-search/)| [Go](./algorithms/go/search.go)|E| |85|[278. 第一个错误的版本](https://leetcode-cn.com/problems/first-bad-version/)| [Go](./algorithms/go/firstBadVersion.go)|E| |86|[509. 斐波那契数](https://leetcode-cn.com/problems/fibonacci-number/)| [Go](./algorithms/go/fib.go)|E| |87|[977. 有序数组的平方](https://leetcode-cn.com/problems/squares-of-a-sorted-array/)| [Go](./algorithms/go/sortedSquares.go)|E| |88|[189. 旋转数组](https://leetcode-cn.com/problems/rotate-array/)| [Go](./algorithms/go/rotate.go)| M| |89|[746. 使用最小花费爬楼梯](https://leetcode-cn.com/problems/min-cost-climbing-stairs/)| [Go](./algorithms/go/minCostClimbingStairs.go)| E| |90|[198. 打家劫舍](https://leetcode-cn.com/problems/house-robber/)| [Go](./algorithms/go/rob.go)| E| |91|[187. 重复的DNA序列](https://leetcode-cn.com/problems/repeated-dna-sequences/)| [Go](./algorithms/go/findRepeatedDnaSequences.go)| M| |92|[20. 有效的括号](https://leetcode-cn.com/problems/valid-parentheses/)| [Go](./algorithms/go/isValid.go)| E| |93|[剑指 Offer 09. 用两个栈实现队列](https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/)| [Go](./algorithms/go/CQueue.go)| E| |94|[232. 用栈实现队列](https://leetcode-cn.com/problems/implement-queue-using-stacks/)| [Go](./algorithms/go/MyQueue.go)| E| |95|[42. 接雨水](https://leetcode-cn.com/problems/trapping-rain-water/)| [Go](./algorithms/go/trap.go)| H| |96|[面试题 08.01. 三步问题](https://leetcode-cn.com/problems/three-steps-problem-lcci/)| [Go](./algorithms/go/waysToStep.go)| E| |97|[50. Pow(x, n)](https://leetcode-cn.com/problems/powx-n/)| [Go](./algorithms/go/myPow.go)| E| |98|[62. 不同路径](https://leetcode-cn.com/problems/unique-paths/)| [Go](./algorithms/go/uniquePaths.go)| M| |99|[63. 不同路径 II](https://leetcode-cn.com/problems/unique-paths-ii/)| [Go](./algorithms/go/uniquePathsWithObstacles.go)| M| |100|[64. 最小路径和](https://leetcode-cn.com/problems/minimum-path-sum/)| [Go](./algorithms/go/minPathSum.go)|M| |101|[111. 二叉树的最小深度](https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/)| [Go](./algorithms/go/minDepth.go)| E| |102|[22. 括号生成](https://leetcode-cn.com/problems/generate-parentheses/)| [Go](./algorithms/go/generateParenthesis.go)| M| |103|[912. 排序数组](https://leetcode-cn.com/problems/sort-an-array/)| [Go](./algorithms/go/sortArray.go)|M| |104|[51. N 皇后](https://leetcode-cn.com/problems/n-queens/)| [Go](./algorithms/go/solveNQueens.go)|H| |105|[319. 灯泡开关](https://leetcode-cn.com/problems/bulb-switcher/)| [Go](./algorithms/go/bulbSwitch.go.go)|M| |106|[344. 反转字符串](https://leetcode-cn.com/problems/reverse-string/)| [Go](./algorithms/go/reverseString.go)|E| |107|[55. 跳跃游戏](https://leetcode-cn.com/problems/jump-game/)| [Go](./algorithms/go/canJump.go)|E| |109|[45. 跳跃游戏 II](https://leetcode-cn.com/problems/jump-game-ii/)| [Go](./algorithms/go/jump2.go)|M| |110|[714. 买卖股票的最佳时机含手续费](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/)| [Go](./algorithms/go/maxProfitFee.go)| M| |111|[123. 买卖股票的最佳时机 III](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii/)| [Go](./algorithms/go/maxProfit2Key.go)| H| |112|[123. 买卖股票的最佳时机 VI](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-vi/)| [Go](./algorithms/go/maxProfit4.go)| H| |113|[剑指 Offer II 026. 重排链表](https://leetcode-cn.com/problems/LGjMqU/)| [Go](./algorithms/go/reorderList.go)|M| |114|[剑指 Offer 47. 礼物的最大价值](https://leetcode-cn.com/problems/li-wu-de-zui-da-jie-zhi-lcof/)| [Go](./algorithms/go/maxValue.go)|M| |115|[剑指 Offer II 078. 合并排序链表](https://leetcode-cn.com/problems/vvXgSW/)| [Go](./algorithms/go/mergeKLists.go)|M| |116|[322. 零钱兑换](https://leetcode-cn.com/problems/coin-change/)| [Go](./algorithms/go/coinChange.go)|M| |117|[剑指 Offer II 003. 前 n 个数字二进制中 1 的个数](https://leetcode-cn.com/problems/w3tCBm/)| [Go](./algorithms/go/countBits.go)|E| |118|[494. 目标和](https://leetcode-cn.com/problems/target-sum/)| [Go](./algorithms/go/findTargetSumWays.go)|M| |119|[213. 打家劫舍 II](https://leetcode-cn.com/problems/house-robber-ii/)| [Go](./algorithms/go/rob2.go)|M| |120|[153. 寻找旋转排序数组中的最小值](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/)| [Go](./algorithms/go/findMin.go)|M| |121|[199. 二叉树的右视图](https://leetcode-cn.com/problems/binary-tree-right-side-view/)| [Go](./algorithms/go/rightSideView.go)|M| |122|[56. 合并区间](https://leetcode-cn.com/problems/merge-intervals/solution/)| [Go](./algorithms/go/merge.go)|M| |123|[39. 组合总和](https://leetcode-cn.com/problems/combination-sum/)| [Go](./algorithms/go/combinationSum.go)|M| |124|[17. 电话号码的字母组合](https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/)| [Go](./algorithms/go/letterCombinations.go)|M| |125|[33. 搜索旋转排序数组](https://leetcode-cn.com/problems/search-in-rotated-sorted-array/)| [Go](./algorithms/go/searchxuan.go)|M| |126|[40. 组合总和 II](https://leetcode-cn.com/problems/combination-sum-ii/)| [Go](./algorithms/go/combinationSum2.go)|M| |127|[47. 全排列 II](https://leetcode-cn.com/problems/permutations-ii/)| [Go](./algorithms/go/permuteUnique.go)|M| |128|[77. 组合](https://leetcode-cn.com/problems/combinations/)| [Go](./algorithms/go/combine.go)|M|