[leetcode] 动规总结

来源于:https://leetcode.com/discuss/general-discussion/458695/Dynamic-Programming-Patterns

Leetcode 上的动态规划题目,可以分为以下几类:

  • Minimum/Maximum Cost to Reach A Target
  • Distinct Ways
  • Merging Intervals
  • DP on strings
  • Decision Making

本文算是翻译一下吧 🙂 ,持续更新。

Min/Max Cost to Reach A Target

题目描述

Given a target find minimum (maximum) cost / path / sum to reach the target.

解题思路

Choose minimum (maximum) path among all possible paths before the current state, then add value for the current state.

转移方程

routes[i] = min(routes[i-1], routes[i-2], ... , routes[i-k]) + cost[i]

关键点:找出当前状态所依赖的历史状态,取最大值/最小值。

习题集:

习题集解答:https://www.cnblogs.com/sinkinben/p/13603240.html

posted @ 2020-09-02 18:16  sinkinben  阅读(149)  评论(0编辑  收藏  举报