https://oj.leetcode.com/tag/dynamic-programming/
本质: 动态规划就是解决了重复计算的搜索
分析思路:递归搜索->记忆搜索->动态规划->动态规划空间降维
动态规划四步骤:#1定义状态 #2递推关系 #3数组初始化 #4返回最后一个值
问题的特征: #1最大/小值 #2Yes/No #3总数 (三者之一)
#1 矩阵的动规
G8: https://oj.leetcode.com/problems/triangle/ 自底向上
G7: https://oj.leetcode.com/problems/minimum-path-sum/
G6: https://oj.leetcode.com/problems/unique-paths/
https://oj.leetcode.com/problems/unique-paths-ii/
https://leetcode.com/problems/dungeon-game/ 自右下到左上
1) 答案是DP最后一个元素
G1: https://oj.leetcode.com/problems/climbing-stairs/ (DP O(N)TIME O(1) SPACE)
本质是Fibonacci有个公式O(1)Time直接算
G2: https://oj.leetcode.com/problems/decode-ways/
DFS也可以 但是DP最优
跟爬楼梯很像,区别在于要判断楼梯是否有效
楼梯判断方法:当前字符有效则可从前一个过来,当前两个字符有效则可从前两个字符过来
https://leetcode.com/problems/jump-game/
https://leetcode.com/problems/jump-game-ii/
https://leetcode.com/problems/palindrome-partitioning-ii/
D4: https://oj.leetcode.com/problems/word-break/ (DFS+MEM或者DP) (DP O(N^2)TIME O(N) SPACE)
https://oj.leetcode.com/problems/word-break-ii/ (DFS+MEM或者DP)
https://leetcode.com/problems/house-robber/
2)答案是DP数据的极值
http://www.lintcode.com/zh-cn/problem/longest-increasing-subsequence/
https://leetcode.com/problems/maximum-subarray/
https://leetcode.com/problems/maximum-product-subarray/
F5: https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/ (DP O(N)TIME O(1) SPACE)
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/ (DP O(N)TIME O(N) SPACE)
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/ (TODO)
G9: https://oj.leetcode.com/problems/edit-distance/ (DP O(MN)TIME O(MN)SPACE) (重)
https://oj.leetcode.com/problems/one-edit-distance/ (非DP)
C19: https://oj.leetcode.com/problems/unique-binary-search-trees/ (DP)
https://leetcode.com/problems/unique-binary-search-trees-ii/ (非DP)