动态规划

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/ 自右下到左上

#2 序列的动规

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)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值