# LeetCodeAlgorithm **Repository Path**: weili_yzzcq/leet-code-algorithm ## Basic Information - **Project Name**: LeetCodeAlgorithm - **Description**: 学习算法,LeetCode刷题,建议经典书籍《算法导论》《算法4》,使用C++和Python语言实现算法,提高算法效率。Algorithm + DataStructure = Programming。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-16 - **Last Updated**: 2022-10-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ![algorithms Logo](./logo.png) > [Wei Li on LeetCode](https://leetcode.cn/u/weili-3z/) ------------------------------------------------------ # 算法理论基础 - 《算法导论》和《算法4》 - 时间复杂度和空间复杂度权衡,时间复杂度的提升是以空间复杂度为代价的 - 仔细观察,LeetCode 上对每一次代码的提交的 执行时间 && 消耗内存 - 效率 = 算法效率 + 编程语言效率 + 计算机硬件效率 - 大O符号 (Big O notation),又称为渐进符号,是用于描述函数渐近行为的数学符号 - 计算机语言有两大特性:生产效率 && 运行效率 - C++ 运行效率比 Python 高;Python 生产效率比 C++ 高 ----------------------------------------------------- # LeetCode 剑指 Offer - CQueue: [剑指 Offer 09. 用两个栈实现队列](https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/) - MinStack2: [剑指 Offer 30. 包含min函数的栈](https://leetcode-cn.com/problems/bao-han-minhan-shu-de-zhan-lcof/) - reversePrint: [剑指 Offer 06. 从尾到头打印链表](https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/) - reverseList2: [剑指 Offer 24. 反转链表](https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/) - copyRandomList: [剑指 Offer 35. 复杂链表的复制](https://leetcode-cn.com/problems/fu-za-lian-biao-de-fu-zhi-lcof/) - replaceSpace: [剑指 Offer 05. 替换空格](https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/) - reverseLeftWords: [剑指 Offer 58 - II. 左旋转字符串](https://leetcode-cn.com/problems/zuo-xuan-zhuan-zi-fu-chuan-lcof/) - findRepeatNumber: [剑指 Offer 03. 数组中重复的数字](https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/) - searchNumber: [在排序数组中查找数字 I](https://leetcode-cn.com/problems/zai-pai-xu-shu-zu-zhong-cha-zhao-shu-zi-lcof/) - missingNumberOnly: [剑指 Offer 53 - II. 0~n-1中缺失的数字](https://leetcode-cn.com/problems/que-shi-de-shu-zi-lcof/) - findNumberIn2DArray: [剑指 Offer 04. 二维数组中的查找](https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/) - minArray: [剑指 Offer 11. 旋转数组的最小数字](https://leetcode-cn.com/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/) - firstUniqChar2: [剑指 Offer 50. 第一个只出现一次的字符](https://leetcode-cn.com/problems/di-yi-ge-zhi-chu-xian-yi-ci-de-zi-fu-lcof/) - levelOrder: [剑指 Offer 32 - I. 从上到下打印二叉树](https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-lcof/) - levelOrderRow: [剑指 Offer 32 - II. 从上到下打印二叉树 II](https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-lcof/) - levelOrderRowCol: [剑指 Offer 32 - III. 从上到下打印二叉树 III](https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-iii-lcof/) - isSubStructure: [剑指 Offer 26. 树的子结构](https://leetcode-cn.com/problems/shu-de-zi-jie-gou-lcof/) - mirrorTree: [剑指 Offer 27. 二叉树的镜像](https://leetcode-cn.com/problems/er-cha-shu-de-jing-xiang-lcof/) - isSymmetricTree: [剑指 Offer 28. 对称的二叉树](https://leetcode-cn.com/problems/dui-cheng-de-er-cha-shu-lcof/) - fib: [剑指 Offer 10- I. 斐波那契数列](https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/) - numWays: [剑指 Offer 10- II. 青蛙跳台阶问题](https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/) - maxProfit2: [剑指 Offer 63. 股票的最大利润](https://leetcode-cn.com/problems/gu-piao-de-zui-da-li-run-lcof/) - maxSubArray2: [剑指 Offer 42. 连续子数组的最大和](https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/) - maxValue: [剑指 Offer 47. 礼物的最大价值](https://leetcode-cn.com/problems/li-wu-de-zui-da-jie-zhi-lcof/) - translateNum: [剑指 Offer 46. 把数字翻译成字符串](https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/) - lengthOfLongestSubstring2: [剑指 Offer 48. 最长不含重复字符的子字符串](https://leetcode-cn.com/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof/) - deleteNode2: [剑指 Offer 18. 删除链表的节点](https://leetcode-cn.com/problems/shan-chu-lian-biao-de-jie-dian-lcof/) - getKthFromEnd: [剑指 Offer 22. 链表中倒数第k个节点](https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/) - mergeTwoLists2: [剑指 Offer 25. 合并两个排序的链表](https://leetcode-cn.com/problems/he-bing-liang-ge-pai-xu-de-lian-biao-lcof/) - getIntersectionNode2: [剑指 Offer 52. 两个链表的第一个公共节点](https://leetcode-cn.com/problems/liang-ge-lian-biao-de-di-yi-ge-gong-gong-jie-dian-lcof/) - exchange: [剑指 Offer 21. 调整数组顺序使奇数位于偶数前面](https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/) - twoSum3: [剑指 Offer 57. 和为s的两个数字](https://leetcode-cn.com/problems/he-wei-sde-liang-ge-shu-zi-lcof/) - reverseWords: [剑指 Offer 58 - I. 翻转单词顺序](https://leetcode-cn.com/problems/fan-zhuan-dan-ci-shun-xu-lcof/) - existMatrix: [剑指 Offer 12. 矩阵中的路径](https://leetcode-cn.com/problems/ju-zhen-zhong-de-lu-jing-lcof/) - movingCount: [剑指 Offer 13. 机器人的运动范围](https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/) - pathSum2: [剑指 Offer 34. 二叉树中和为某一值的路径](https://leetcode-cn.com/problems/er-cha-shu-zhong-he-wei-mou-yi-zhi-de-lu-jing-lcof/) - treeToDoublyList: [剑指 Offer 36. 二叉搜索树与双向链表](https://leetcode-cn.com/problems/er-cha-sou-suo-shu-yu-shuang-xiang-lian-biao-lcof/) - kthLargest: [剑指 Offer 54. 二叉搜索树的第k大节点](https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof/) - minNumber: [剑指 Offer 45. 把数组排成最小的数](https://leetcode-cn.com/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/) - isStraight: [剑指 Offer 61. 扑克牌中的顺子](https://leetcode-cn.com/problems/bu-ke-pai-zhong-de-shun-zi-lcof/) - getLeastNumbers: [剑指 Offer 40. 最小的k个数](https://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof/) - medianFinder: [剑指 Offer 41. 数据流中的中位数](https://leetcode-cn.com/problems/shu-ju-liu-zhong-de-zhong-wei-shu-lcof/) - maxDepthTree: [剑指 Offer 55 - I. 二叉树的深度](https://leetcode-cn.com/problems/er-cha-shu-de-shen-du-lcof/) - isBalancedTree: [剑指 Offer 55 - II. 平衡二叉树](https://leetcode-cn.com/problems/ping-heng-er-cha-shu-lcof/) - sumNums: [剑指 Offer 64. 求1+2+…+n](https://leetcode-cn.com/problems/qiu-12n-lcof/) - lowestCommonAncestor3: [剑指 Offer 68 - I. 二叉搜索树的最近公共祖先](https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-zui-jin-gong-gong-zu-xian-lcof/) - lowestCommonAncestor4: [剑指 Offer 68 - II. 二叉树的最近公共祖先](https://leetcode-cn.com/problems/er-cha-shu-de-zui-jin-gong-gong-zu-xian-lcof/) - buildTree3: [剑指 Offer 07. 重建二叉树](https://leetcode-cn.com/problems/zhong-jian-er-cha-shu-lcof/) - myPow: [剑指 Offer 16. 数值的整数次方](https://leetcode-cn.com/problems/shu-zhi-de-zheng-shu-ci-fang-lcof/) - verifyPostorder: [剑指 Offer 33. 二叉搜索树的后序遍历序列](https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/) - addAlgorithm: [剑指 Offer 65. 不用加减乘除做加法](https://leetcode-cn.com/problems/bu-yong-jia-jian-cheng-chu-zuo-jia-fa-lcof/) - singleNumbers: [剑指 Offer 56 - I. 数组中数字出现的次数](https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-lcof/) - singleNumberTwo: [剑指 Offer 56 - II. 数组中数字出现的次数 II](https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-ii-lcof/) - majorityElementArray: [剑指 Offer 39. 数组中出现次数超过一半的数字](https://leetcode-cn.com/problems/shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-lcof/) - constructArr: [剑指 Offer 66. 构建乘积数组](https://leetcode-cn.com/problems/gou-jian-cheng-ji-shu-zu-lcof/) - cuttingRope: [剑指 Offer 14- I. 剪绳子](https://leetcode-cn.com/problems/jian-sheng-zi-lcof/) - findContinuousSequence: [剑指 Offer 57 - II. 和为s的连续正数序列](https://leetcode-cn.com/problems/he-wei-sde-lian-xu-zheng-shu-xu-lie-lcof/) - lastRemaining: [剑指 Offer 62. 圆圈中最后剩下的数字](https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/) - spiralOrder: [剑指 Offer 29. 顺时针打印矩阵](https://leetcode-cn.com/problems/shun-shi-zhen-da-yin-ju-zhen-lcof/) - validateStackSequences: [剑指 Offer 31. 栈的压入、弹出序列](https://leetcode-cn.com/problems/zhan-de-ya-ru-dan-chu-xu-lie-lcof/) - isNumberStr: [剑指 Offer 20. 表示数值的字符串](https://leetcode-cn.com/problems/biao-shi-shu-zhi-de-zi-fu-chuan-lcof/) - strToInt: [剑指 Offer 67. 把字符串转换成整数](https://leetcode-cn.com/problems/ba-zi-fu-chuan-zhuan-huan-cheng-zheng-shu-lcof/) - maxSlidingWindowNums: [剑指 Offer 59 - I. 滑动窗口的最大值](https://leetcode-cn.com/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/) - MaxQueue: [剑指 Offer 59 - II. 队列的最大值](https://leetcode-cn.com/problems/dui-lie-de-zui-da-zhi-lcof/) - serialize: [剑指 Offer 37. 序列化二叉树](https://leetcode-cn.com/problems/xu-lie-hua-er-cha-shu-lcof/) - permutation: [剑指 Offer 38. 字符串的排列](https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/) - isMatchRegular: [剑指 Offer 19. 正则表达式匹配](https://leetcode-cn.com/problems/zheng-ze-biao-da-shi-pi-pei-lcof/) - nthUglyNumber: [剑指 Offer 49. 丑数](https://leetcode-cn.com/problems/chou-shu-lcof/) - dicesProbability: [剑指 Offer 60. n个骰子的点数](https://leetcode-cn.com/problems/nge-tou-zi-de-dian-shu-lcof/) # LeetCode 分类刷题 [数组] https://leetcode-cn.com/tag/array/problemset/ - removeDuplicates: [26. 删除有序数组中的重复项](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/) - removeElement: [27. 移除元素](https://leetcode-cn.com/problems/remove-element/) - maxArea: [11. 盛最多水的容器](https://leetcode-cn.com/problems/container-with-most-water/) - threeSum: [15. 三数之和](https://leetcode-cn.com/problems/3sum/) - threeSumClosest: [16. 最接近的三数之和](https://leetcode-cn.com/problems/3sum-closest/) - firstMissingPositive: [41. 缺失的第一个正数](https://leetcode-cn.com/problems/first-missing-positive/) - largestRectangleArea: [84. 柱状图中最大的矩形](https://leetcode-cn.com/problems/largest-rectangle-in-histogram/) - trap: [42. 接雨水](https://leetcode-cn.com/problems/trapping-rain-water/) - maximalRectangle: [85. 最大矩形](https://leetcode-cn.com/problems/maximal-rectangle/) [字符串] https://leetcode-cn.com/tag/string/problemset/ - romanToInt: [13. 罗马数字转整数](https://leetcode-cn.com/problems/roman-to-integer/) - longestCommonPrefix: [14. 最长公共前缀](https://leetcode-cn.com/problems/longest-common-prefix/) - convert: [6. Z 字形变换](https://leetcode-cn.com/problems/zigzag-conversion/) - myAtoi: [8. 字符串转换整数 (atoi)](https://leetcode-cn.com/problems/string-to-integer-atoi/) - intToRoman: [12. 整数转罗马数字](https://leetcode-cn.com/problems/integer-to-roman/) - findSubstring: [30. 串联所有单词的子串](https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/) - longestValidParentheses: [32. 最长有效括号](https://leetcode-cn.com/problems/longest-valid-parentheses/) - isMatchSimple: [44. 通配符匹配](https://leetcode-cn.com/problems/wildcard-matching/) - isNumber: [65. 有效数字](https://leetcode-cn.com/problems/valid-number/) [贪心] https://leetcode-cn.com/tag/greedy/problemset/ - arrayPairSum: [561. 数组拆分 I](https://leetcode-cn.com/problems/array-partition-i/) - lemonadeChange: [860. 柠檬水找零](https://leetcode-cn.com/problems/lemonade-change/) - jump: [45. 跳跃游戏 II](https://leetcode-cn.com/problems/jump-game-ii/) - canJump: [55. 跳跃游戏](https://leetcode-cn.com/problems/jump-game/) - canCompleteCircuit: [134. 加油站](https://leetcode-cn.com/problems/gas-station/) - maxNumber: [321. 拼接最大数](https://leetcode-cn.com/problems/create-maximum-number/) - minPatches: [330. 按要求补齐数组](https://leetcode-cn.com/problems/patching-array/) - splitArray: [410. 分割数组的最大值](https://leetcode-cn.com/problems/split-array-largest-sum/) - findMaximizedCapital: [502. IPO](https://leetcode-cn.com/problems/ipo/) [双指针] https://leetcode-cn.com/tag/two-pointers/problemset/ - isPalindromeCheck: [125. 验证回文串](https://leetcode-cn.com/problems/valid-palindrome/) - hasCycle: [141. 环形链表](https://leetcode-cn.com/problems/linked-list-cycle/) - moveZeroes: [283. 移动零](https://leetcode-cn.com/problems/move-zeroes/) - fourSum: [18. 四数之和](https://leetcode-cn.com/problems/4sum/) - nextPermutation: [31. 下一个排列](https://leetcode-cn.com/problems/next-permutation/) - maxSum: [1537. 最大得分](https://leetcode-cn.com/problems/get-the-maximum-score/) - smallestDistancePair: [719. 找出第 k 小的距离对](https://leetcode-cn.com/problems/find-k-th-smallest-pair-distance/) - countPairs: [1782. 统计点对的数目](https://leetcode-cn.com/problems/count-pairs-of-nodes/) - trapMIN: [面试题 17.21. 直方图的水量](https://leetcode-cn.com/problems/volume-of-histogram-lcci/) [哈希表] https://leetcode-cn.com/tag/hash-table/problemset/ - wordPattern: [290. 单词规律](https://leetcode-cn.com/problems/word-pattern/) - firstUniqChar: [387. 字符串中的第一个唯一字符](https://leetcode-cn.com/problems/first-unique-character-in-a-string/) - letterCombinations: [17. 电话号码的字母组合](https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/) - groupAnagrams: [49. 字母异位词分组](https://leetcode-cn.com/problems/group-anagrams/) - setZeroes: [73. 矩阵置零](https://leetcode-cn.com/problems/set-matrix-zeroes/) - countOfAtoms: [726. 原子的数量](https://leetcode-cn.com/problems/number-of-atoms/) - smallestRange: [632. 最小区间](https://leetcode-cn.com/problems/smallest-range-covering-elements-from-k-lists/) - findNumOfValidWords: [1178. 猜字谜](https://leetcode-cn.com/problems/number-of-valid-words-for-each-puzzle/) - longestAwesome: [1542. 找出最长的超赞子字符串](https://leetcode-cn.com/problems/find-longest-awesome-substring/) [动态规划] https://leetcode-cn.com/tag/dynamic-programming/problemset/ - generate: [118. 杨辉三角](https://leetcode-cn.com/problems/pascals-triangle/) - minCostClimbingStairs: [746. 使用最小花费爬楼梯](https://leetcode-cn.com/problems/min-cost-climbing-stairs/) - uniquePaths: [62. 不同路径](https://leetcode-cn.com/problems/unique-paths/) - minimumTotal: [120. 三角形最小路径和](https://leetcode-cn.com/problems/triangle/) - numTrees: [96. 不同的二叉搜索树](https://leetcode-cn.com/problems/unique-binary-search-trees/) - isScramble: [87. 扰乱字符串](https://leetcode-cn.com/problems/scramble-string/) - numDistinct: [115. 不同的子序列](https://leetcode-cn.com/problems/distinct-subsequences/) - maxPathSum: [124. 二叉树中的最大路径和](https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/) - longestIncreasingPath: [329. 矩阵中的最长递增路径](https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix/) ----------------------------------------------------- # Reference LeetCode 101: A LeetCode Grinding Guide (C++ Version) ----------------------------------------------------- # C++ & Python 实现 LeetCode 算法题 ## 贪心策略 - find_content_children:[455. 分发饼干](https://leetcode-cn.com/problems/assign-cookies/) - candy: [135. 分发糖果](https://leetcode-cn.com/problems/candy/) - erase_overlap_intervals: [435. 无重叠区间](https://leetcode-cn.com/problems/non-overlapping-intervals/) - canPlaceFlowers: [605. 种花问题](https://leetcode-cn.com/problems/can-place-flowers/) - findMinArrowShots: [452. 用最少数量的箭引爆气球](https://leetcode-cn.com/problems/minimum-number-of-arrows-to-burst-balloons/) - partitionLabels: [763. 划分字母区间](https://leetcode-cn.com/problems/partition-labels/) - maxProfit: [122. 买卖股票的最佳时机 II](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/) - reconstructQueue: [406. 根据身高重建队列](https://leetcode-cn.com/problems/queue-reconstruction-by-height/) - checkPossibility: [665. 非递减数列](https://leetcode-cn.com/problems/non-decreasing-array/) ## 双指针 - twoSum2: [167. 两数之和 II - 输入有序数组](https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted/) - merge: [88. 合并两个有序数组](https://leetcode-cn.com/problems/merge-sorted-array/) - detectCycle: [142. 环形链表 II](https://leetcode-cn.com/problems/linked-list-cycle-ii/) - minWindow: [76. 最小覆盖子串](https://leetcode-cn.com/problems/minimum-window-substring/) - judgeSquareSum: [633. 平方数之和](https://leetcode-cn.com/problems/sum-of-square-numbers/) - validPalindrome: [680. 验证回文字符串 Ⅱ](https://leetcode-cn.com/problems/valid-palindrome-ii/) - findLongestWord: [524. 通过删除字母匹配到字典里最长单词](https://leetcode-cn.com/problems/longest-word-in-dictionary-through-deleting/) ## 二分查找 - mySqrt: [69. x 的平方根](https://leetcode-cn.com/problems/sqrtx/) - searchRange: [34. 在排序数组中查找元素的第一个和最后一个位置](https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/) - search: [81. 搜索旋转排序数组 II](https://leetcode-cn.com/problems/search-in-rotated-sorted-array-ii/) - findMin: [154. 寻找旋转排序数组中的最小值 II](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/) - singleNonDuplicate: [540. 有序数组中的单一元素](https://leetcode-cn.com/problems/single-element-in-a-sorted-array/) - findMedianSortedArrays: [4. 寻找两个正序数组的中位数](https://leetcode-cn.com/problems/median-of-two-sorted-arrays/) ## 排序算法 - common_sort_algorithms: 快速排序;归并排序;插入排序;冒泡排序;选择排序 - findKthLargest: [215. 数组中的第K个最大元素](https://leetcode-cn.com/problems/kth-largest-element-in-an-array/) - topKFrequent: [347. 前 K 个高频元素](https://leetcode-cn.com/problems/top-k-frequent-elements/) - frequencySort: [3451. 根据字符出现频率排序](https://leetcode-cn.com/problems/sort-characters-by-frequency/) - sortColors: [75. 颜色分类](https://leetcode-cn.com/problems/sort-colors/) ## 搜索算法 - 深度优先搜索(depth-first seach, DFS) && 广度优先搜索(Breadth first search, BFS) - maxAreaOfIsland: [695. 岛屿的最大面积](https://leetcode-cn.com/problems/max-area-of-island/) - findCircleNum: [547. 省份数量](https://leetcode-cn.com/problems/number-of-provinces/) - pacificAtlantic: [417. 太平洋大西洋水流问题](https://leetcode-cn.com/problems/pacific-atlantic-water-flow/) - permute: [46. 全排列](https://leetcode-cn.com/problems/permutations/) - combine: [77. 组合](https://leetcode-cn.com/problems/combinations/) - exist: [79. 单词搜索](https://leetcode-cn.com/problems/word-search/) - solveNQueens: [51. N 皇后](https://leetcode-cn.com/problems/n-queens/) - shortestBridge: [934. 最短的桥](https://leetcode-cn.com/problems/shortest-bridge/) - findLadders: [126. 单词接龙 II](https://leetcode-cn.com/problems/word-ladder-ii/) - solve: [130. 被围绕的区域](https://leetcode-cn.com/problems/surrounded-regions/) - binaryTreePaths: [257. 二叉树的所有路径](https://leetcode-cn.com/problems/binary-tree-paths/) - permuteUnique: [47. 全排列 II](https://leetcode-cn.com/problems/permutations-ii/) - combinationSum2: [40. 组合总和 II](https://leetcode-cn.com/problems/combination-sum-ii/) - solveSudoku: [37. 解数独](https://leetcode-cn.com/problems/sudoku-solver/) - findMinHeightTrees: [310. 最小高度树](https://leetcode-cn.com/problems/minimum-height-trees/) ## 动态规划 - climbStairs: [70. 爬楼梯](https://leetcode-cn.com/problems/climbing-stairs/) - rob: [198. 打家劫舍](https://leetcode-cn.com/problems/house-robber/) - numberOfArithmeticSlices: [413. 等差数列划分](https://leetcode-cn.com/problems/arithmetic-slices/) - minPathSum: [64. 最小路径和](https://leetcode-cn.com/problems/minimum-path-sum/) - updateMatrix: [542. 01 矩阵](https://leetcode-cn.com/problems/01-matrix/) - maximalSquare: [221. 最大正方形](https://leetcode-cn.com/problems/maximal-square/) - numSquares: [279. 完全平方数](https://leetcode-cn.com/problems/perfect-squares/) - numDecodings: [91. 解码方法](https://leetcode-cn.com/problems/decode-ways/) - wordBreak: [139. 单词拆分](https://leetcode-cn.com/problems/word-break/) - lengthOfLIS: [300. 最长递增子序列](https://leetcode-cn.com/problems/longest-increasing-subsequence/) - longestCommonSubsequence: [1143. 最长公共子序列](https://leetcode-cn.com/problems/longest-common-subsequence/) - canPartition: [416. 分割等和子集](https://leetcode-cn.com/problems/partition-equal-subset-sum/) - findMaxForm: [474. 一和零](https://leetcode-cn.com/problems/ones-and-zeroes/) - coinChange: [322. 零钱兑换](https://leetcode-cn.com/problems/coin-change/) - minDistance: [72. 编辑距离](https://leetcode-cn.com/problems/edit-distance/) - minSteps: [650. 只有两个键的键盘](https://leetcode-cn.com/problems/2-keys-keyboard/) - isMatch: [10. 正则表达式匹配](https://leetcode-cn.com/problems/regular-expression-matching/) - maxProfitChance: [121. 买卖股票的最佳时机](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/) - maxProfitChance2: [188. 买卖股票的最佳时机 IV](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iv/) - maxProfitChanceCooldown: [309. 最佳买卖股票时机含冷冻期](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/) - rob2: [213. 打家劫舍 II](https://leetcode-cn.com/problems/house-robber-ii/) - maxSubArray: [53. 最大子序和](https://leetcode-cn.com/problems/maximum-subarray/) - integerBreak: [343. 整数拆分](https://leetcode-cn.com/problems/integer-break/) - minDistanceDelete: [583. 两个字符串的删除操作](https://leetcode-cn.com/problems/delete-operation-for-two-strings/) - findLongestChain: [646. 最长数对链](https://leetcode-cn.com/problems/maximum-length-of-pair-chain/) - wiggleMaxLength: [376. 摆动序列](https://leetcode-cn.com/problems/wiggle-subsequence/) - findTargetSumWays: [494. 目标和](https://leetcode-cn.com/problems/target-sum/) - maxProfitFree: [714. 买卖股票的最佳时机含手续费](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/) ## 分治策略 - diffWaysToCompute: [241. 为运算表达式设计优先级](https://leetcode-cn.com/problems/different-ways-to-add-parentheses/) - beautifulArray: [932. 漂亮数组](https://leetcode-cn.com/problems/beautiful-array/) - maxCoins: [312. 戳气球](https://leetcode-cn.com/problems/burst-balloons/) ## 数学问题 - countPrimes: [204. 计数质数](https://leetcode-cn.com/problems/count-primes/) - convertToBase7: [504. 七进制数](https://leetcode-cn.com/problems/base-7/) - trailingZeroes: [172. 阶乘后的零](https://leetcode-cn.com/problems/factorial-trailing-zeroes/) - addStrings: [415. 字符串相加](https://leetcode-cn.com/problems/add-strings/) - isPowerOfThree: [326. 3的幂](https://leetcode-cn.com/problems/power-of-three/) - shuffleReset: [384. 打乱数组](https://leetcode-cn.com/problems/shuffle-an-array/) - pickIndex: [528. 按权重随机选择](https://leetcode-cn.com/problems/random-pick-with-weight/) - getRandom: [382. 链表随机节点](https://leetcode-cn.com/problems/linked-list-random-node/) - convertToTitle: [168. Excel表列名称](https://leetcode-cn.com/problems/excel-sheet-column-title/) - addBinary: [67. 二进制求和](https://leetcode-cn.com/problems/add-binary/) - productExceptSelf: [238. 除自身以外数组的乘积](https://leetcode-cn.com/problems/product-of-array-except-self/) - minMoves2: [462. 最少移动次数使数组元素相等 II](https://leetcode-cn.com/problems/minimum-moves-to-equal-array-elements-ii/) - majorityElement: [169. 多数元素](https://leetcode-cn.com/problems/majority-element/) - isHappy: [202. 快乐数](https://leetcode-cn.com/problems/happy-number/) ## 位运算操作 - hammingDistance: [461. 汉明距离](https://leetcode-cn.com/problems/hamming-distance/) - reverseBits: [190. 颠倒二进制位](https://leetcode-cn.com/problems/reverse-bits/) - singleNumber: [136. 只出现一次的数字](https://leetcode-cn.com/problems/single-number/) - isPowerOfFour: [342. 4的幂](https://leetcode-cn.com/problems/power-of-four/) - maxProduct: [318. 最大单词长度乘积](https://leetcode-cn.com/problems/maximum-product-of-word-lengths/) - countBits: [338. 比特位计数](https://leetcode-cn.com/problems/counting-bits/) - missingNumber: [268. 丢失的数字](https://leetcode-cn.com/problems/missing-number/) - hasAlternatingBits: [693. 交替位二进制数](https://leetcode-cn.com/problems/binary-number-with-alternating-bits/) - findComplement: [476. 数字的补数](https://leetcode-cn.com/problems/number-complement/) - singleNumber3: [260. 只出现一次的数字 III](https://leetcode-cn.com/problems/single-number-iii/) ## 数据结构(C++) - findDisappearedNumbers: [448. 找到所有数组中消失的数字](https://leetcode-cn.com/problems/find-all-numbers-disappeared-in-an-array/) - rotateImage: [48. 旋转图像](https://leetcode-cn.com/problems/rotate-image/) - searchMatrix: [240. 搜索二维矩阵 II](https://leetcode-cn.com/problems/search-a-2d-matrix-ii/) - maxChunksToSorted: [769. 最多能完成排序的块](https://leetcode-cn.com/problems/max-chunks-to-make-sorted/) - MyQueue: [232. 用栈实现队列](https://leetcode-cn.com/problems/implement-queue-using-stacks/) - MinStack : [155. 最小栈](https://leetcode-cn.com/problems/min-stack/) - isValid : [20. 有效的括号](https://leetcode-cn.com/problems/valid-parentheses/) - dailyTemperatures : [739. 每日温度](https://leetcode-cn.com/problems/daily-temperatures/) - mergeKLists : [23. 合并K个升序链表](https://leetcode-cn.com/problems/merge-k-sorted-lists/) - getSkyline : [218. 天际线问题](https://leetcode-cn.com/problems/the-skyline-problem/) - maxSlidingWindow : [239. 滑动窗口最大值](https://leetcode-cn.com/problems/sliding-window-maximum/) - longestConsecutive : [128. 最长连续序列](https://leetcode-cn.com/problems/longest-consecutive-sequence/) - maxPoints : [149. 直线上最多的点数](https://leetcode-cn.com/problems/max-points-on-a-line/) - findItinerary : [332. 重新安排行程](https://leetcode-cn.com/problems/reconstruct-itinerary/) - NumArray : [303. 区域和检索 - 数组不可变](https://leetcode-cn.com/problems/range-sum-query-immutable/) - NumMatrix : [304. 二维区域和检索 - 矩阵不可变](https://leetcode-cn.com/problems/range-sum-query-2d-immutable/) - subarraySum : [560. 和为K的子数组](https://leetcode-cn.com/problems/subarray-sum-equals-k/) - matrixReshape : [566. 重塑矩阵](https://leetcode-cn.com/problems/reshape-the-matrix/) - MyStack : [225. 用队列实现栈](https://leetcode-cn.com/problems/implement-stack-using-queues/) - nextGreaterElements : [503. 下一个更大元素 II](https://leetcode-cn.com/problems/next-greater-element-ii/) - containsDuplicate : [217. 存在重复元素](https://leetcode-cn.com/problems/contains-duplicate/) - findShortestSubArray : [697. 数组的度](https://leetcode-cn.com/problems/degree-of-an-array/) - findLHS : [594. 最长和谐子序列](https://leetcode-cn.com/problems/longest-harmonious-subsequence/) - findDuplicate : [287. 寻找重复数](https://leetcode-cn.com/problems/find-the-duplicate-number/) - nthSuperUglyNumber : [313. 超级丑数](https://leetcode-cn.com/problems/super-ugly-number/) - advantageCount : [870. 优势洗牌](https://leetcode-cn.com/problems/advantage-shuffle/) - NumArray2 : [307. 区域和检索 - 数组可修改](https://leetcode-cn.com/problems/range-sum-query-mutable/) ## 字符串 - isAnagram : [242. 有效的字母异位词](https://leetcode-cn.com/problems/valid-anagram/) - isIsomorphic : [205. 同构字符串](https://leetcode-cn.com/problems/isomorphic-strings/) - countSubstrings : [647. 回文子串](https://leetcode-cn.com/problems/palindromic-substrings/) - countBinarySubstrings : [696. 计数二进制子串](https://leetcode-cn.com/problems/count-binary-substrings/) - calculate : [227. 基本计算器 II](https://leetcode-cn.com/problems/basic-calculator-ii/) - strStr : [28. 实现 strStr()](https://leetcode-cn.com/problems/implement-strstr/) - longestPalindrome : [409. 最长回文串](https://leetcode-cn.com/problems/longest-palindrome/) - lengthOfLongestSubstring : [3. 无重复字符的最长子串](https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/) - longestSubPalindrome : [5. 最长回文子串](https://leetcode-cn.com/problems/longest-palindromic-substring/) ## 指针-链表 - reverseList : [206. 反转链表](https://leetcode-cn.com/problems/reverse-linked-list/) - mergeTwoLists : [21. 合并两个有序链表](https://leetcode-cn.com/problems/merge-two-sorted-lists/) - swapPairs : [24. 两两交换链表中的节点](https://leetcode-cn.com/problems/swap-nodes-in-pairs/) - getIntersectionNode : [160. 相交链表](https://leetcode-cn.com/problems/intersection-of-two-linked-lists/) - isPalindrome : [234. 回文链表](https://leetcode-cn.com/problems/palindrome-linked-list/) - deleteDuplicates : [83. 删除排序链表中的重复元素](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/) - oddEvenList : [328. 奇偶链表](https://leetcode-cn.com/problems/odd-even-linked-list/) - removeNthFromEnd : [19. 删除链表的倒数第 N 个结点](https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/) - sortList : [148. 排序链表](https://leetcode-cn.com/problems/sort-list/) ## 指针-树 - maxDepth : [104. 二叉树的最大深度](https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/) - isBalanced : [110. 平衡二叉树](https://leetcode-cn.com/problems/balanced-binary-tree/) - diameterOfBinaryTree : [543. 二叉树的直径](https://leetcode-cn.com/problems/diameter-of-binary-tree/) - pathSum : [437. 路径总和 III](https://leetcode-cn.com/problems/path-sum-iii/) - isSymmetric : [101. 对称二叉树](https://leetcode-cn.com/problems/symmetric-tree/) - delNodes : [1110. 删点成林](https://leetcode-cn.com/problems/delete-nodes-and-return-forest/) - averageOfLevels : [637. 二叉树的层平均值](https://leetcode-cn.com/problems/average-of-levels-in-binary-tree/) - buildTree : [105. 从前序与中序遍历序列构造二叉树](https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) - preorderTraversal : [144. 二叉树的前序遍历](https://leetcode-cn.com/problems/binary-tree-preorder-traversal/) - recoverTree : [99. 恢复二叉搜索树](https://leetcode-cn.com/problems/recover-binary-search-tree/) - trimBST : [669. 修剪二叉搜索树](https://leetcode-cn.com/problems/trim-a-binary-search-tree/) - Trie : [208. 实现 Trie (前缀树)](https://leetcode-cn.com/problems/implement-trie-prefix-tree/) - invertTree : [226. 翻转二叉树](https://leetcode-cn.com/problems/invert-binary-tree/) - mergeTrees : [617. 合并二叉树](https://leetcode-cn.com/problems/merge-two-binary-trees/) - isSubtree : [572. 另一棵树的子树](https://leetcode-cn.com/problems/subtree-of-another-tree/) - sumOfLeftLeaves : [404. 左叶子之和](https://leetcode-cn.com/problems/sum-of-left-leaves/) - findBottomLeftValue : [513. 找树左下角的值](https://leetcode-cn.com/problems/find-bottom-left-tree-value/) - convertBST : [538. 把二叉搜索树转换为累加树](https://leetcode-cn.com/problems/convert-bst-to-greater-tree/) - lowestCommonAncestor : [235. 二叉搜索树的最近公共祖先](https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-search-tree/) - getMinimumDifference : [530. 二叉搜索树的最小绝对差](https://leetcode-cn.com/problems/minimum-absolute-difference-in-bst/) - constructFromPrePost : [889. 根据前序和后序遍历构造二叉树](https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/) - buildTree2 : [106. 从中序与后序遍历序列构造二叉树](https://leetcode-cn.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) - inorderTraversal : [94. 二叉树的中序遍历](https://leetcode-cn.com/problems/binary-tree-inorder-traversal/) - postorderTraversal : [145. 二叉树的后序遍历](https://leetcode-cn.com/problems/binary-tree-postorder-traversal/) - lowestCommonAncestor2 : [236. 二叉树的最近公共祖先](https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/) - sortedListToBST : [109. 有序链表转换二叉搜索树](https://leetcode-cn.com/problems/convert-sorted-list-to-binary-search-tree/) - increasingBST : [897. 递增顺序搜索树](https://leetcode-cn.com/problems/increasing-order-search-tree/) - findTarget2 : [653. 两数之和 IV - 输入 BST](https://leetcode-cn.com/problems/two-sum-iv-input-is-a-bst/) - deleteNode : [450. 删除二叉搜索树中的节点](https://leetcode-cn.com/problems/delete-node-in-a-bst/) ## 指针-图 - isBipartite : [785. 判断二分图](https://leetcode-cn.com/problems/is-graph-bipartite/) - findOrder : [210. 课程表 II](https://leetcode-cn.com/problems/course-schedule-ii/) - reachableNodes : [882. 细分图中的可到达结点](https://leetcode-cn.com/problems/reachable-nodes-in-subdivided-graph/) ## 复杂的数据结构——并查集 - findRedundantConnection : [684. 冗余连接](https://leetcode-cn.com/problems/redundant-connection/) - LRUCache : [146. LRU 缓存机制](https://leetcode-cn.com/problems/lru-cache/) - RandomizedSet : [380. O(1) 时间插入、删除和获取随机元素](https://leetcode-cn.com/problems/insert-delete-getrandom-o1/) - AllOne : [432. 全 O(1) 的数据结构](https://leetcode-cn.com/problems/all-oone-data-structure/) - AllOne : [432. 全 O(1) 的数据结构](https://leetcode-cn.com/problems/all-oone-data-structure/) ----------------------------------------------------- # Coding Standard - [Google style for CPP](https://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/contents/) - [Google style for Python](https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/contents/) - 命名一定有一套规范,尽量与普遍的规范一致 - 算法或者数据结构的编码实现 - 首先要弄懂算法或者数据结构的基本原理 - 然后针对使用的编程语言进行思考 - 最后动手开始编码 ## 命名约定 - 变量名,全部小写,尽量英文单词,做到见名知意,单词之间使用下划线分隔 - 函数名,首字母大写,尽量英文单词,单词之间使用下划线分隔,小驼峰命名法 - 类名,首字母大写,尽量英文单词,单词之间不需要使用下划线分隔,大驼峰命名法 - 文件名,全部小写,尽量英文单词,做到见名知意,单词之间使用下划线分隔 - 在此中可能使用一些常见的算法的缩写以及约定俗成的写法, 例如,梯度下降算法 GD,不需要的变量 _ ----------------------------------------------------- # About Author ## 掌中星辰转日月,手心苍穹天外天。                   ——云主宰苍穹 ## Stay Hungry, Stay Foolish.                   ——Steve Jobs - Mail:2694048168@qq.com - Weibo:云主宰苍穹 - GitHub: https://github.com/2694048168/ - Gitee:https://gitee.com/weili_yzzcq/ -----------------------------------------------------