# leetcode **Repository Path**: aijit/leetcode ## Basic Information - **Project Name**: leetcode - **Description**: No description available - **Primary Language**: C++ - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-27 - **Last Updated**: 2022-05-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: Cpp, Algorithm, LeetCode ## README # 日拱一卒,功不唐捐 ## 贪心 [517. 超级洗衣机](https://leetcode-cn.com/problems/super-washing-machines) [121. 买卖股票的最佳时机](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock) [502. IPO](https://leetcode-cn.com/problems/ipo)「大顶堆」 [55. 跳跃游戏](https://leetcode-cn.com/problems/jump-game) [45. 跳跃游戏 II](https://leetcode-cn.com/problems/jump-game-ii) [881. 救生艇](https://leetcode-cn.com/problems/boats-to-save-people) [1833. 雪糕的最大数量](https://leetcode-cn.com/problems/maximum-ice-cream-bars/) [12. 整数转罗马数字](https://leetcode-cn.com/problems/integer-to-roman/) [300. 最长递增子序列](https://leetcode-cn.com/problems/longest-increasing-subsequence)「贪心+二分, DP」 [1713. 得到子序列的最少操作次数](https://leetcode-cn.com/problems/minimum-operations-to-make-a-subsequence) [1846. 减小和重新排列数组后的最大元素](https://leetcode-cn.com/problems/maximum-element-after-decreasing-and-rearranging) ## 动态规则 [629. K个逆序对数组](https://leetcode-cn.com/problems/k-inverse-pairs-array) [494. 目标和](https://leetcode-cn.com/problems/target-sum) [416. 分割等和子集](https://leetcode-cn.com/problems/partition-equal-subset-sum) [322. 零钱兑换](https://leetcode-cn.com/problems/coin-change) [312. 戳气球](https://leetcode-cn.com/problems/burst-balloons) [309. 最佳买卖股票时机含冷冻期](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-cooldown) [279. 完全平方数](https://leetcode-cn.com/problems/perfect-squares) [221. 最大正方形](https://leetcode-cn.com/problems/maximal-square) [198. 打家劫舍](https://leetcode-cn.com/problems/house-robber) [91. 解码方法](https://leetcode-cn.com/problems/decode-ways) [639. 解码方法 II](https://leetcode-cn.com/problems/decode-ways-ii) [139. 单词拆分](https://leetcode-cn.com/problems/word-break) [1143. 最长公共子序列](https://leetcode-cn.com/problems/longest-common-subsequence) [583. 两个字符串的删除操作](https://leetcode-cn.com/problems/delete-operation-for-two-strings) [673. 最长递增子序列的个数](https://leetcode-cn.com/problems/number-of-longest-increasing-subsequence) [63. 不同路径 II](https://leetcode-cn.com/problems/unique-paths-ii) [72. 编辑距离](https://leetcode-cn.com/problems/edit-distance) [600. 不含连续1的非负整数](https://leetcode-cn.com/problems/non-negative-integers-without-consecutive-ones) [10. 正则表达式匹配](https://leetcode-cn.com/problems/regular-expression-matching/) [44. 通配符匹配](https://leetcode-cn.com/problems/wildcard-matching) [剑指 Offer 42.连续子数组的最大和](https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/) [32. 最长有效括号](https://leetcode-cn.com/problems/longest-valid-parentheses) [38. 外观数列](https://leetcode-cn.com/problems/count-and-say) [264. 丑数 II](https://leetcode-cn.com/problems/ugly-number-ii) [313. 超级丑数](https://leetcode-cn.com/problems/super-ugly-number) [1201. 丑数 III](https://leetcode-cn.com/problems/ugly-number-iii) [446. 等差数列划分 II - 子序列](https://leetcode-cn.com/problems/arithmetic-slices-ii-subsequence) [516. 最长回文子序列](https://leetcode-cn.com/problems/longest-palindromic-subsequence) [576. 出界的路径数](https://leetcode-cn.com/problems/out-of-boundary-paths) [552. 学生出勤记录 II](https://leetcode-cn.com/problems/student-attendance-record-ii) [787. K 站中转内最便宜的航班](https://leetcode-cn.com/problems/cheapest-flights-within-k-stops) [1928. 规定时间内到达终点的最小花费](https://leetcode-cn.com/problems/minimum-cost-to-reach-destination-in-time) [1981. 最小化目标值与所选元素的差](https://leetcode-cn.com/problems/minimize-the-difference-between-target-and-chosen-elements)「分组背包」 [53. 最大子序和](https://leetcode-cn.com/problems/maximum-subarray)「前缀和」 [152. 乘积最大子数组](https://leetcode-cn.com/problems/maximum-product-subarray) ## 排序 [406. 根据身高重建队列](https://leetcode-cn.com/problems/queue-reconstruction-by-height) [148. 排序链表](https://leetcode-cn.com/problems/sort-list)「归并排序」 [5864. 游戏中弱角色的数量](https://leetcode-cn.com/problems/the-number-of-weak-characters-in-the-game) [451. 根据字符出现频率排序](https://leetcode-cn.com/problems/sort-characters-by-frequency/)「桶排序」 [645. 错误的集合](https://leetcode-cn.com/problems/set-mismatch/) [274. H 指数](https://leetcode-cn.com/problems/h-index/)「计数(桶)排序」 ## 查找 [1610. 可见点的最大数目](https://leetcode-cn.com/problems/maximum-number-of-visible-points)「极角,二分查找」 [352. 将数据流变为多个不相交区间](https://leetcode-cn.com/problems/data-stream-as-disjoint-intervals)「map二分查找」 [981. 基于时间的键值存储](https://leetcode-cn.com/problems/time-based-key-value-store/)「二分查找」 [34. 在排序数组中查找元素的第一个和最后一个位置](https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array) [1337. 矩阵中战斗力最弱的 K 行](https://leetcode-cn.com/problems/the-k-weakest-rows-in-a-matrix) ## 搜索 [638. 大礼包](https://leetcode-cn.com/problems/shopping-offers) [301. 删除无效的括号](https://leetcode-cn.com/problems/remove-invalid-parentheses) [240. 搜索二维矩阵 II](https://leetcode-cn.com/problems/search-a-2d-matrix-ii) [282. 给表达式添加运算符](https://leetcode-cn.com/problems/expression-add-operators)「回溯」 [200. 岛屿数量](https://leetcode-cn.com/problems/number-of-islands)「DFS」 [102. 二叉树的层序遍历](https://leetcode-cn.com/problems/binary-tree-level-order-traversal)「BFS」 [79. 单词搜索](https://leetcode-cn.com/problems/word-search)「记忆化搜索」 [46. 全排列](https://leetcode-cn.com/problems/permutations)「DFS」 [47. 全排列 II](https://leetcode-cn.com/problems/permutations-ii)「DFS+剪枝」 [797. 所有可能的路径](https://leetcode-cn.com/problems/all-paths-from-source-to-target)「DFS」 [17. 电话号码的字母组合](https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/)「回溯」 [22. 括号生成](https://leetcode-cn.com/problems/generate-parentheses/)「回溯」 [815. 公交路线](https://leetcode-cn.com/problems/bus-routes/)「BFS」 [LCP 07. 传递信息](https://leetcode-cn.com/problems/chuan-di-xin-xi/)「DFS, DP」 [37. 解数独](https://leetcode-cn.com/problems/sudoku-solver)「回溯」 [51. N 皇后](https://leetcode-cn.com/problems/n-queens)「回溯」 [52. N皇后 II](https://leetcode-cn.com/problems/n-queens-ii)「回溯」 [802. 找到最终的安全状态](https://leetcode-cn.com/problems/find-eventual-safe-states)「三色标记」 [39. 组合总和](https://leetcode-cn.com/problems/combination-sum)「回溯」 [40. 组合总和 II](https://leetcode-cn.com/problems/combination-sum-ii) [5832. 构造元素不等于两相邻元素平均值的数组](https://leetcode-cn.com/contest/weekly-contest-254/problems/array-with-elements-not-equal-to-average-of-neighbors/)「~~DFS~~ 排序」 [526. 优美的排列](https://leetcode-cn.com/problems/beautiful-arrangement)「回溯, DP」 ## Hash [869. 重新排序得到 2 的幂](https://leetcode-cn.com/problems/reordered-power-of-2) [128. 最长连续序列](https://leetcode-cn.com/problems/longest-consecutive-sequence) [442. 数组中重复的数据](https://leetcode-cn.com/problems/find-all-duplicates-in-an-array)「原地Hash」 [1418. 点菜展示表](https://leetcode-cn.com/problems/display-table-of-food-orders-in-a-restaurant/) [1711. 大餐计数](https://leetcode-cn.com/problems/count-good-meals/)「互补 Key , 桶」 [1. 两数之和](https://leetcode-cn.com/problems/two-sum/)「互补 Key」 [560. 和为 K 的子数组](https://leetcode-cn.com/problems/subarray-sum-equals-k)「前缀和, 互补 Key」 [49. 字母异位词分组](https://leetcode-cn.com/problems/group-anagrams/) 同 [面试题 10.02. 变位词组](https://leetcode-cn.com/problems/group-anagrams-lcci/) ## 位运算 [136. 只出现一次的数字](https://leetcode-cn.com/problems/single-number)「异或 b^a^b=a」 [371. 两整数之和](https://leetcode-cn.com/problems/sum-of-two-integers) [1603. 设计停车系统](https://leetcode-cn.com/problems/design-parking-system) [5851. 找出不同的二进制字符串](https://leetcode-cn.com/problems/find-unique-binary-string) ## 字符串 [647. 回文子串](https://leetcode-cn.com/problems/palindromic-substrings)「中心扩展」 [5. 最长回文子串](https://leetcode-cn.com/problems/longest-palindromic-substring/)「DP」 [6. Z 字形变换](https://leetcode-cn.com/problems/zigzag-conversion/) [8. 字符串转换整数 (atoi)](https://leetcode-cn.com/problems/string-to-integer-atoi/) [394. 字符串解码](https://leetcode-cn.com/problems/decode-string) ## 数组 [238. 除自身以外数组的乘积](https://leetcode-cn.com/problems/product-of-array-except-self)「前缀积、后缀积」 [169. 多数元素](https://leetcode-cn.com/problems/majority-element/)「摩尔投票」 [面试题 17.10. 主要元素](https://leetcode-cn.com/problems/find-majority-element-lcci/) [1818. 绝对差值和](https://leetcode-cn.com/problems/minimum-absolute-sum-difference/)「二分查找」 ## 堆 [786. 第 K 个最小的素数分数](https://leetcode-cn.com/problems/k-th-smallest-prime-fraction)「小顶堆」 [347. 前 K 个高频元素](https://leetcode-cn.com/problems/top-k-frequent-elements)「小顶堆」 [253. 会议室 II](https://leetcode-cn.com/problems/meeting-rooms-ii/)「小顶堆」 [面试题 17.14. 最小K个数](https://leetcode-cn.com/problems/smallest-k-lcci)「大顶堆」 [295. 数据流的中位数](https://leetcode-cn.com/problems/find-median-from-data-stream)「小/大顶堆」 [218. 天际线问题](https://leetcode-cn.com/problems/the-skyline-problem/)「大顶堆」 ## 栈 [739. 每日温度](https://leetcode-cn.com/problems/daily-temperatures) [84. 柱状图中最大的矩形](https://leetcode-cn.com/problems/largest-rectangle-in-histogram)「单调栈」[85. 最大矩形](https://leetcode-cn.com/problems/maximal-rectangle) [42. 接雨水](https://leetcode-cn.com/problems/trapping-rain-water)「单调栈」 [407. 接雨水 II](https://leetcode-cn.com/problems/trapping-rain-water-ii)「单调栈」 [726. 原子的数量](https://leetcode-cn.com/problems/number-of-atoms/) [20. 有效的括号](https://leetcode-cn.com/problems/valid-parentheses/) [678. 有效的括号字符串](https://leetcode-cn.com/problems/valid-parenthesis-string) [232. 用栈实现队列](https://leetcode-cn.com/problems/implement-queue-using-stacks) ## 队列 [225. 用队列实现栈](https://leetcode-cn.com/problems/implement-stack-using-queues) ## 指针 [142. 环形链表 II](https://leetcode-cn.com/problems/linked-list-cycle-ii)「快慢指针」 [287. 寻找重复数](https://leetcode-cn.com/problems/find-the-duplicate-number) [80. 删除有序数组中的重复项 II](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array-ii)「快慢指针」 [75. 颜色分类](https://leetcode-cn.com/problems/sort-colors)「双指针, 荷兰国旗问题」 [11. 盛最多水的容器](https://leetcode-cn.com/problems/container-with-most-water/)「双指针」 [14. 最长公共前缀](https://leetcode-cn.com/problems/longest-common-prefix/) [15. 三数之和](https://leetcode-cn.com/problems/3sum/) [16. 最接近的三数之和](https://leetcode-cn.com/problems/3sum-closest/) [18. 四数之和](https://leetcode-cn.com/problems/4sum/) [581. 最短无序连续子数组](https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray) [611. 有效三角形的个数](https://leetcode-cn.com/problems/valid-triangle-number)「双指针」 [443. 压缩字符串](https://leetcode-cn.com/problems/string-compression)「双指针」 ## 滑动窗口 [438. 找到字符串中所有字母异位词](https://leetcode-cn.com/problems/find-all-anagrams-in-a-string)「数组key」 [76. 最小覆盖子串](https://leetcode-cn.com/problems/minimum-window-substring) [930. 和相同的二元子数组](https://leetcode-cn.com/problems/binary-subarrays-with-sum/) [30. 串联所有单词的子串](https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words) [1838. 最高频元素的频数](https://leetcode-cn.com/problems/frequency-of-the-most-frequent-element) ## 链表 [234. 回文链表](https://leetcode-cn.com/problems/palindrome-linked-list) [725. 分隔链表](https://leetcode-cn.com/problems/split-linked-list-in-parts) [146. LRU 缓存机制](https://leetcode-cn.com/problems/lru-cache)「双向链表」 [19. 删除链表的倒数第 N 个结点](https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/)「双指针」 [21. 合并两个有序链表](https://leetcode-cn.com/problems/merge-two-sorted-lists/) [23. 合并K个升序链表](https://leetcode-cn.com/problems/merge-k-sorted-lists/)「分治」 [24. 两两交换链表中的节点](https://leetcode-cn.com/problems/swap-nodes-in-pairs/) [206. 反转链表](https://leetcode-cn.com/problems/reverse-linked-list/) [25. K 个一组翻转链表](https://leetcode-cn.com/problems/reverse-nodes-in-k-group/) [61. 旋转链表](https://leetcode-cn.com/problems/rotate-list) [160. 相交链表](https://leetcode-cn.com/problems/intersection-of-two-linked-lists)、 [剑指 Offer 52. 两个链表的第一个公共节点](https://leetcode-cn.com/problems/liang-ge-lian-biao-de-di-yi-ge-gong-gong-jie-dian-lcof) [138. 复制带随机指针的链表](https://leetcode-cn.com/problems/copy-list-with-random-pointer) ## 树 [538. 把二叉搜索树转换为累加树](https://leetcode-cn.com/problems/convert-bst-to-greater-tree) [337. 打家劫舍 III](https://leetcode-cn.com/problems/house-robber-iii) [230. 二叉搜索树中第K小的元素](https://leetcode-cn.com/problems/kth-smallest-element-in-a-bst)「中序遍历」 [236. 二叉树的最近公共祖先](https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree) [124. 二叉树中的最大路径和](https://leetcode-cn.com/problems/binary-tree-maximum-path-sum) [105. 从前序与中序遍历序列构造二叉树](https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal) [98. 验证二叉搜索树](https://leetcode-cn.com/problems/validate-binary-search-tree)「中序遍历」 [94. 二叉树的中序遍历](https://leetcode-cn.com/problems/binary-tree-inorder-traversal)「递归, 迭代, 莫里斯遍历」 [671. 二叉树中第二小的节点](https://leetcode-cn.com/problems/second-minimum-node-in-a-binary-tree) [863. 二叉树中所有距离为 K 的结点](https://leetcode-cn.com/problems/all-nodes-distance-k-in-binary-tree) [1104. 二叉树寻路](https://leetcode-cn.com/problems/path-in-zigzag-labelled-binary-tree) [987. 二叉树的垂序遍历](https://leetcode-cn.com/problems/vertical-order-traversal-of-a-binary-tree) [208. 实现 Trie (前缀树)](https://leetcode-cn.com/problems/implement-trie-prefix-tree)「字典树」 [212. 单词搜索 II](https://leetcode-cn.com/problems/word-search-ii)「字典树+DFS」 ## 图 [399. 除法求值](https://leetcode-cn.com/problems/evaluate-division)「并查集」 [207. 课程表](https://leetcode-cn.com/problems/course-schedule)「三色标记」 [210. 课程表 II](https://leetcode-cn.com/problems/course-schedule-ii)「拓扑排序」 [1976. 到达目的地的方案数](https://leetcode-cn.com/problems/number-of-ways-to-arrive-at-destination)「有向图 , 单源最短路径」 [1743. 从相邻元素对还原数组](https://leetcode-cn.com/problems/restore-the-array-from-adjacent-pairs) [743. 网络延迟时间](https://leetcode-cn.com/problems/network-delay-time) [847. 访问所有节点的最短路径](https://leetcode-cn.com/problems/shortest-path-visiting-all-nodes)「BFS」 [457. 环形数组是否存在循环](https://leetcode-cn.com/problems/circular-array-loop)「快慢指针」 ## 代数 [166. 分数到小数](https://leetcode-cn.com/problems/fraction-to-recurring-decimal)「长除法」 [96. 不同的二叉搜索树](https://leetcode-cn.com/problems/unique-binary-search-trees)「卡塔兰数」 [48. 旋转图像](https://leetcode-cn.com/problems/rotate-image)「矩阵操作」 [50. Pow(x, n)](https://leetcode-cn.com/problems/powx-n)「快速幂」 [剑指 Offer 10- I. 斐波那契数列](https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof) [43. 字符串相乘](https://leetcode-cn.com/problems/multiply-strings) [LCP 29. 乐团站位](https://leetcode-cn.com/problems/SNJvJP) [7. 整数反转](https://leetcode-cn.com/problems/reverse-integer/) [9. 回文数](https://leetcode-cn.com/problems/palindrome-number/) [29. 两数相除](https://leetcode-cn.com/problems/divide-two-integers/) [31. 下一个排列](https://leetcode-cn.com/problems/next-permutation) [60. 排列序列](https://leetcode-cn.com/problems/permutation-sequence)「第 k 个排列」 [36. 有效的数独](https://leetcode-cn.com/problems/valid-sudoku) [413. 等差数列划分](https://leetcode-cn.com/problems/arithmetic-slices) [233. 数字 1 的个数](https://leetcode-cn.com/problems/number-of-digit-one) [5835. 最大方阵和](https://leetcode-cn.com/problems/maximum-matrix-sum) [789. 逃脱阻碍者](https://leetcode-cn.com/problems/escape-the-ghosts)「曼哈顿距离」 ### 差分 [1893. 检查是否区域内所有整数都被覆盖](https://leetcode-cn.com/problems/check-if-all-the-integers-in-a-range-are-covered)「差分数组 , 前缀和」 [1109. 航班预订统计](https://leetcode-cn.com/problems/corporate-flight-bookings)「差分数组 , 前缀和」 ### 前缀和 [437. 路径总和 III](https://leetcode-cn.com/problems/path-sum-iii) [5882. 网格游戏](https://leetcode-cn.com/problems/grid-game) [528. 按权重随机选择](https://leetcode-cn.com/problems/random-pick-with-weight)「前缀和」 [1894. 找到需要补充粉笔的学生编号](https://leetcode-cn.com/problems/find-the-student-that-will-replace-the-chalk)「前缀和」 ## 几何 [223. 矩形面积](https://leetcode-cn.com/problems/rectangle-area) [391. 完美矩形](https://leetcode-cn.com/problems/perfect-rectangle) ## 模拟 [621. 任务调度器](https://leetcode-cn.com/problems/task-scheduler) [54. 螺旋矩阵](https://leetcode-cn.com/problems/spiral-matrix) [59. 螺旋矩阵 II](https://leetcode-cn.com/problems/spiral-matrix-ii) [57. 插入区间](https://leetcode-cn.com/problems/insert-interval) ## 状态机 [65. 有效数字](https://leetcode-cn.com/problems/valid-number) ![有效数字状态图](questions/65.有效数字/state_machine.jpg) ## 引用 [Text to ASCII Art Generator](http://patorjk.com/software/taag/#p=display&f=Ogre&t=mud) [vscode extension: supperchong algorithm](https://github.com/supperchong/algorithm)