Dynamic programming
http://blog.csdn.net/linhuanmars/article/details/38468361
state machine
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/
坐标型 20%
f[i] 第i个
https://leetcode.com/problems/word-break/description/ https://leetcode.com/problems/concatenated-words/description/ https://leetcode.com/problems/unique-paths/
Divide & conquer, solve with 2 pass: order and reversed order https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/description/ https://leetcode.com/problems/bomb-enemy https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/description/
LIS problem https://leetcode.com/problems/longest-increasing-subsequence https://leetcode.com/problems/russian-doll-envelopes/description/ https://leetcode.com/problems/increasing-triplet-subsequence https://leetcode.com/problems/maximum-length-of-pair-chain https://leetcode.com/problems/number-of-longest-increasing-subsequence https://leetcode.com/problems/increasing-subsequences/description/ https://leetcode.com/problems/longest-continuous-increasing-subsequence/description/
序列型 20%
f[i] 前i个
can be O(1) variable or O(n)/1D variable
these problems are conditional, discuss different situation:
https://leetcode.com/problems/paint-fence/description/ https://leetcode.com/problems/paint-house/description/ https://leetcode.com/problems/paint-house-ii/description/ https://leetcode.com/problems/maximum-vacation-days/description/ https://leetcode.com/problems/house-robber/ https://leetcode.com/problems/house-robber-ii/description/ https://leetcode.com/problems/climbing-stairs/ https://leetcode.com/problems/maximum-subarray/description/
局部最优和全局最优 https://leetcode.com/problems/maximum-product-subarray/description/ https://leetcode.com/problems/maximum-subarray
Stocks: the whole series key point: buy and sell must cannot happen together, because if price go down, it's buy point, selling here get 0 profit, meaningless. if price go up, it's sell point, won't buy. buy2 must happen before sell1, because if not, buy2 will be negative, won't update.
https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/ https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/description/ https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/
双序列型
https://leetcode.com/problems/edit-distance/ https://leetcode.com/problems/regular-expression-matching/ https://leetcode.com/problems/wildcard-matching/description/ https://leetcode.com/problems/distinct-subsequences/description/ https://leetcode.com/problems/minimum-window-subsequence/description/ https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings https://leetcode.com/problems/delete-operation-for-two-strings
划分型 20%
https://leetcode.com/problems/decode-ways/ https://leetcode.com/problems/decode-ways-ii https://leetcode.com/problems/house-robber-iii
区间型 15%
https://leetcode.com/problems/longest-palindromic-substring/description/
背包型 10% coin change
https://blog.csdn.net/wzy_1988/article/details/12260343
https://leetcode.com/problems/partition-equal-subset-sum/description/ https://leetcode.com/problems/partition-to-k-equal-sum-subsets/description/ https://leetcode.com/problems/combination-sum-iv/description/ https://leetcode.com/problems/coin-change/description/ https://leetcode.com/problems/target-sum/description/ https://leetcode.com/problems/ones-and-zeroes/description/ https://leetcode.com/problems/non-negative-integers-without-consecutive-ones/description/ https://leetcode.com/problems/non-negative-integers-without-consecutive-ones/description/ https://leetcode.com/problems/house-robber-ii
from 1 to k
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/description/ https://leetcode.com/problems/partition-to-k-equal-sum-subsets/description/ https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/description/
subproblem
these problems are not DP, but there ideas are similar: solving subproblem. https://leetcode.com/problems/count-of-smaller-numbers-after-self/description/ https://leetcode.com/problems/count-of-range-sum/description/ https://leetcode.com/problems/reverse-pairs/description/
dp + divide&conquer
it's not only one subproblem, instead, many subproblems need to be compared or processed. https://leetcode.com/problems/encode-string-with-shortest-length/description/ https://leetcode.com/problems/unique-binary-search-trees/description/
MiniMax problem (3D DP)
most game problem https://leetcode.com/problems/guess-number-higher-or-lower-ii/description/ https://leetcode.com/problems/can-i-win/description/
3 for-loop -> DFS + Memo https://leetcode.com/problems/split-array-largest-sum/description/ https://leetcode.com/problems/burst-balloons/
https://leetcode.com/problems/largest-sum-of-averages/description/ https://leetcode.com/problems/knight-probability-in-chessboard/description/
https://leetcode.com/problems/encode-string-with-shortest-length/description/
https://leetcode.com/discuss/general-discussion/592146/dynamic-programming-summary/513130
1. Number Tower,数塔
118. Pascal's Triangle
(Easy)
、118. 杨辉三角(简单)
119. Pascal's Triangle II
(Easy)
、119. 杨辉三角 II(简单)
64. Minimum Path Sum
(Medium)
、64. 最小路径和(中等)
120. Triangle
(Medium)
、120. 三角形最小路径和(中等)
931. Minimum Falling Path Sum
(Medium)
、931. 下降路径最小和(中等)
2. Fibonacci Numbers,斐波那契数列
Fibonacci numbers,斐波那契数列问题
509. Fibonacci Number
(Easy)
、509. 斐波那契数(简单)
1137. N-th Tribonacci Number
(Easy)
、1137. 第 N 个泰波那契数(简单)
Staircase,爬楼梯问题
70. Climbing Stairs
(Easy)
、70. 爬楼梯(简单)
746. Min Cost Climbing Stairs
(Easy)
、746. 使用最小花费爬楼梯(简单)
House thief,偷房子问题
198. House Robber
(Easy)
、198. 打家劫舍(简单)
213. House Robber II
(Medium)
、213. 打家劫舍 II(中等)
3. Memory Search,记忆化搜索
139. Word Break
Medium
、139. 单词拆分中等
4. 0/1 Knapsack, 0/1 背包
Equal Subset Sum Partition,相等子集划分问题
416. Partition Equal Subset Sum
(Medium)
、416. 分割等和子集(中等)
Subset Sum,子集和问题
494. Target Sum
(Medium)
、494. 目标和(中等)
Minimum Subset Sum Difference,子集和的最小差问题
1049. Last Stone Weight II
(Medium)
、1049. 最后一块石头的重量 II(中等)
Other,其它
474. Ones and Zeroes
(Medium)
、474. 一和零(中等)
5. Unbounded Knapsack,无限(完全)背包
Coin Change,换硬币问题
322. Coin Change
(Medium)
、322. 零钱兑换(中等)
518. Coin Change 2
(Medium)
、518. 零钱兑换 II(中等)
Others,其它
377. Combination Sum IV
(Medium)
、377. 组合总和 Ⅳ(中等)
638. Shopping Offers
(Medium)
、638. 大礼包(中等)
6. Counting DP,计数 DP
62. Unique Paths
(Medium)
、62. 不同路径(中等)
63. Unique Paths II
(Medium)
、63. 不同路径 II(中等)
91. Decode Ways
(Medium)
、91. 解码方法(中等)
576. Out of Boundary Paths
(Medium)
、576. 出界的路径数(中等)
790. Domino and Tromino Tiling
(Medium)
、790. 多米诺和托米诺平铺(中等)
935. Knight Dialer
(Medium)
、935. 骑士拨号器(中等)
1641. Count Sorted Vowel Strings
(Medium)
、1641. 统计字典序元音字符串的数目(中等)
1223. Dice Roll Simulation
(Medium)
、1223. 掷骰子模拟(中等)
7. Probability DP,概率 DP
808. Soup Servings
(Medium)
、808. 分汤(中等)
8. Tree DP,树状 DP
96. Unique Binary Search Trees
(Medium)
、96. 不同的二叉搜索树(中等)
823. Binary Trees With Factors
(Medium)
、823. 带因子的二叉树(中等)
968. Binary Tree Cameras
(Hard)
、968. 监控二叉树(困难)
9. Optimal Solution,最优解问题
Math,数学相关
279. Perfect Squares
(Medium)
、279. 完全平方数(中等)
368. Largest Divisible Subset
(Medium)
、368. 最大整除子集(中等)
646. Maximum Length of Pair Chain
(Medium)
、646. 最长数对链(中等)
650. 2 Keys Keyboard
(Medium)
、650. 只有两个键的键盘(中等)
813. Largest Sum of Averages
(Medium)
、813. 最大平均值和的分组(中等)
1262. Greatest Sum Divisible by Three
(Medium)
、1262. 可被三整除的最大和(中等)
1537. Get the Maximum Score
(Hard)
、1537. 最大得分(困难)
Buy and Sell Stock,股票买卖问题
983. Minimum Cost For Tickets
(Medium)
、983. 最低票价(中等)
Paint House,粉刷房子问题
256. Paint House
(Easy)
、256. 粉刷房子(简单)
265. Paint House II
(Hard)
、265. 粉刷房子 II(困难)
1473. Paint House III
(Hard)
、1473. 给房子涂色 III(困难)
Job Schedule,工作计划问题
Minimum Number of Operations,最少操作次数问题
514. Freedom Trail
(Hard)
、514. 自由之路(困难)
10. Can I Win? 博弈 DP
292. Nim Game
(Easy)
、292. Nim 游戏(简单)
1025. Divisor Game
(Easy)
、1025. 除数博弈(简单)
464. Can I Win
(Medium)
、464. 我能赢吗(中等)
486. Predict the Winner
(Medium)
、486. 预测赢家(中等)
877. Stone Game
(Medium)
、877. 石子游戏(中等)
1140. Stone Game II
(Medium)
、1140. 石子游戏 II(中等)
1406. Stone Game III
(Hard)
、1406. 石子游戏 III(困难)
1510. Stone Game IV
(Hard)
、1510. 石子游戏 IV(困难)
11. Interval DP,区间 DP
Intervals Merge,区间合并
312. Burst Balloons
(Hard)
、312. 戳气球(困难)
546. Remove Boxes
(Hard)
、546. 移除盒子(困难)
664. Strange Printer
(Hard)
、664. 奇怪的打印机(困难)
1478. Allocate Mailboxes
(Hard)
、1478. 安排邮筒(困难)
1563. Stone Game V
(Hard)
、1563. 石子游戏 V(困难)
Triangulation,三角剖分
Rectangle Segmentation,矩形分割
221. Maximal Square
(Medium)
、221. 最大正方形(中等)
1139. Largest 1-Bordered Square
(Medium)
、1139. 最大的以 1 为边界的正方形(中等)
85. Maximal Rectangle
(Hard)
、85. 最大矩形(困难)
12. Subsequence/Substring,子序列/子字符串
12.1. Longest Subsequence/Substring,最长子序列/子字符串
Longest Common Substring,最长公共子串
718. Maximum Length of Repeated Subarray
(Medium)
、718. 最长重复子数组(中等)
Longest Common Subsequence,最长公共子序列
1035. Uncrossed Lines
(Medium)
、1035. 不相交的线(中等)
1143. Longest Common Subsequence
(Medium)
、1143. 最长公共子序列(中等)
Longest Increasing Subsequence,最长上升子序列
300. Longest Increasing Subsequence
(Medium)
、300. 最长上升子序列(中等)
354. Russian Doll Envelopes
(Hard)
、354. 俄罗斯套娃信封问题(困难)
Shortest Common Super-sequence,最短公共超级子序列
Others,其它
12.2. Palindromic Subsequence/Substring,回文子序列/子字符串
Longest Palindromic Subsequence,最长回文子序列
516. Longest Palindromic Subsequence
(Medium)
、516. 最长回文子序列(中等)
Longest Palindromic Substring,最长回文子字符串
5. Longest Palindromic Substring
(Medium)
、5. 最长回文子串(中等)
Count Palindromic Subsequences/Substrings,回文子序列/子字符串的个数
647. Palindromic Substrings
(Medium)
、647. 回文子串(中等)
Palindromic Partitioning,回文分割
131. Palindrome Partitioning
(Medium)
、131. 分割回文串(中等)
132. Palindrome Partitioning II
(Hard)
、132. 分割回文串 II(困难)
13. String,字符串上的动态规划
13.1. String Transform,字符串变换
583. Delete Operation for Two Strings
(Medium)
、583. 两个字符串的删除操作(中等)
72. Edit Distance
(Hard)
、72. 编辑距离(困难)
97. Interleaving String
(Hard)
、97. 交错字符串(困难)
13.2. Regular Expression Matching,正则表达式匹配
678. Valid Parenthesis String
(Medium)
、678. 有效的括号字符串(中等)
10. Regular Expression Matching
(Hard)
、10. 正则表达式匹配(困难)
44. Wildcard Matching
(Hard)
、44. 通配符匹配(困难)
639. Decode Ways II
(Hard)
、639. 解码方法 2(困难)
14. Multi-start state,多起始状态
741. Cherry Pickup
(Hard)
、741. 摘樱桃(困难)
1463. Cherry Pickup II
(Hard)
、1463. 摘樱桃 II(困难)
15. DP Optimizition,DP 优化
837. New 21 Game
(Medium)
、837. 新 21 点(中等)
1340. Jump Game V
(Hard)
、1340. 跳跃游戏 V(困难)
1416. Restore The Array
(Hard)
、1416. 恢复数组(困难)
1425. Constrained Subset Sum
(Hard)
、1425. 带限制的子序列和(困难)
15. Bitmask DP,状态压缩 DP
1125. Smallest Sufficient Team
(Hard)
、1125. 最小的必要团队(困难)
16. 轮廓线动态规划
1659. Maximize Grid Happiness
(Hard)
、1659. 最大化网格幸福感(困难)
Last updated