Created by gh-md-toc
原数组==[O(n)]==>前缀和数组==[O(1)]==>范围和==[O(n)]==>差分数组
原数组<==[O(n)]==前缀和数组
原数组<==[O(n)]==差分数组
原数组<==[O(n^2)]==范围和
- 1109. Corporate Flight Bookings: 差分数组
- 560. Subarray Sum Equals K: 前缀和数组
- 380. Insert Delete GetRandom O(1)
- 710. Random Pick with Blacklist
符号位替代哈希表
- offer3. 数组中的重复数字
- 448. Find All Numbers Disappeared in an Array
- 645. Set Mismatch
- 41. First Missing Positive
众数
- 572. Subtree of Another Tree
- 100. Same Tree
- 226. Invert Binary Tree
- 654. Maximum Binary Tree
- 114. Flatten Binary Tree to Linked List
- 110. Balanced Binary Tree
- 112. Path Sum
- 113. Path Sum II
- 104. Maximum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 222. Count Complete Tree Nodes
- 101. Symmetric Tree
- 116. Populating Next Right Pointers in Each Node
- 236. Lowest Common Ancestor of a Binary Tree
- 652. Find Duplicate Subtrees
- 144. Binary Tree Preorder Traversal: 前序遍历
- 94. Binary Tree Inorder Traversal: 中序遍历
- 145. Binary Tree Postorder Traversal: 后序遍历
- 102. Binary Tree Level Order Traversal: 层序遍历
- offer8. 二叉树的下一个节点
- offer32. 从上到下打印二叉树 III
- 105. Construct Binary Tree from Preorder and Inorder Traversal: 先跟+中根
- 106. Construct Binary Tree from Inorder and Postorder Traversal: 中根+后跟
- 889. Construct Binary Tree from Preorder and Postorder Traversal: 先跟+后跟
- offer37. 序列化二叉树
- 98. Validate Binary Search Tree
- 700. Search in a Binary Search Tree
- 701. Insert into a Binary Search Tree
- 450. Delete Node in a BST
- 538. Convert BST to Greater Tree
- 230. Kth Smallest Element in a BST
- offer54. 二叉搜索树的第k大节点
- offer33. 二叉搜索树的后序遍历序列
- offer36. 二叉搜索树与双向链表
- offer68. 二叉搜索树的最近公共祖先
PreviousNode, CurrentNode, NextNode, head, tail and sentinel nodes
- 234. Palindrome Linked List
- 206. Reverse Linked List
- 92. Reverse Linked List II
- 25. Reverse Nodes in k-Group
- 141. Linked List Cycle
- 142. Linked List Cycle II
- 2. Add Two Numbers
- 21. Merge Two Sorted Lists
- 61. Rotate List
- 138. Copy List With Random Pointer
- 160. Intersection Of Two Linked Lists
- 430. Flatten A Multilevel Doubly Linked List
- 707. Design Linked List
- offer6. 从尾到头打印链表
- 445. Add Two Numbers II
- 316. Remove Duplicate Letters
- 20. Valid Parentheses
- offer9. 用两个栈实现队列
- offer31. 栈的压入、弹出序列
从一个方向看数组,前方的元素会将后面的较小元素阻挡
若从前往后看,却从后往前遍历,则需要记录下可以看到的元素到栈中,所以栈中的元素是单调的,就是单调栈
每次新元素入栈后,不断弹出比新元素小(大)的栈顶元素
- 496. Next Greater Element I
- 503. Next Greater Element II
- offer30. 包含min函数的栈
- 739. Daily Temperatures
- 456. 132 Pattern
从一个方向看数组,前方的元素会将后面的较小元素阻挡
若从后往前看,却从前往后遍历,则需要记录下可以看到的元素到队列中,所以栈中的元素是单调的,就是单调队列
每次新元素入栈后,不断将比新元素小(大)的队尾元素出队
- offer46. 把数字翻译成字符串
- offer47. 礼物的最大值
- 887. Super Egg Drop
- 877. Stone Game
- 28. Implement strStr(): 字符串匹配算法
- 264. ugly number II
- Offer60. n个骰子的点数
区间问题
- 435. Non-overlapping Intervals
- 452. Minimum Number of Arrows to Burst Balloons
- 1288. Remove Covered Intervals
- 56. Merge Intervals
- 986. Interval List Intersections
- 354. Russian Doll Envelopes
- 子串(sub array): 原序列的连续元素的组成的新序列
- 子序列(sub sequence): 原序列的非连续元素(符合原序列顺序)的组成的新序列
dp[i]: 以第i个元素结尾的序列
回文序列是自身与自身比较也是双序列问题,
dp[i, j]: 序列; 子串->i,j元素结尾
- 72. Edit Distance
- 10. Regular Expression Matching
- 1312. Minimum Insertion Steps to Make a String Palindrome
- 5. Longest Palindromic Substring
- 1143. Longest Common Subsequence
- 516. Longest Palindromic Subsequence
-
0-1 背包:物品反向枚举
-
完全背包:物品正向枚举
-
最值或者组合个数需要体现在状态转移方程中
-
322. Coin Change: 完全背包
-
518. Coin Change II: 完全背包
-
494. Target Sum: 0-1背包
-
474. Ones and Zeroes: 多重背包
- 121. Best Time to Buy and Sell Stock
- 122. Best Time to Buy and Sell Stock II
- 123. Best Time to Buy and Sell Stock III
- 188. Best Time to Buy and Sell Stock IV
- 309. Best Time to Buy and Sell Stock with Cooldown
- 714. Best Time to Buy and Sell Stock with Transaction Fee
- 34. Find First and Last Position of Element in Sorted Array: 上下界查找
- offer4. 二维数组中的查找
- offer11. 旋转数组的最小数字
- offer53. 0~n-1中缺失的数字
- 793. Preimage Size of Factorial Zeroes Function
- 392. Is Subsequence
- 141. LinkedListCycle
- 19. Remove Nth Node From End of List
- 141. Linked List Cycle
- 142. Linked List Cycle II
- 26. Remove Duplicates from Sorted Array
- 83. Remove Duplicates from Sorted List
- 82. Remove Duplicates from Sorted List II
- 19. Remove Nth Node From End of List
- 27. Remove Element
- 283. Move Zeroes
- 76. Minimum Window Substring
- 438. Find All Anagrams in a String
- 567. Permutation in String
- offer48. 最长不含重复字符的子字符串
- offer57. 和为s的连续正数序列
- offer58. 翻转单词顺序
- 167. two sum II - input array is sorted
- 15. 3sum
- 16. 3sum closest
- 923. 3sum with multiplicity
- 18. 4Sum
- 42. trapping rain water
- 5. Longest Palindromic Substring
- offer12. 矩阵中的路径
- 51. N-Queens
- 52. N-Queens II
- offer13. 机器人的运动范围
- offer17. 打印从1到最大的n位数
- 130. Surrounded Regions
- 37. Sudoku Solver
- 22. Generate Parentheses
- offer1. 单例模式 线程安全的单例模式
- offer20. 表示数值的字符串
- offer67. 把字符串转换成整数
- 921. Minimum Add to Make Parentheses Valid
- 1541. Minimum Insertions to Balance a Parentheses String
- offer61. 扑克牌中的顺子
- 341. Flatten Nested List Iterator
- 43. Multiply Strings
- 969. Pancake Sorting
- 855. Exam Room
- offer43. 1~n整数中1出现的次数
- offer29. 顺时针打印矩阵
- offer44. 数字序列中某一位的数字
- offer45. 把数组排成最小的数
- offer62. 圆圈中最后剩下的数字: 约瑟夫环
- offer66. 构建乘积数组
- 391. Perfect Rectangle
- 172. Factorial Trailing Zeroes
- 204. Count Primes
- 263. Ugly Number
- 912. Sort an Array.cpp: 内排序算法
- 310. Minimum Height Trees: 拓扑排序
- 215. Kth Largest Element in an Array
- 347. Top K Frequent Elements
- offer51. 数组中的逆序对