Description
Usually, One-dimensional dynamic planning problem, the parameter is always $n$, the result is similar to number sequence $a_n$, or $f(n)$($f$ can be viewed as function or corresponding relationship). At the same time, there will be certain corresponding relationship between $a_n$ and $a_{n - 1}, a_{n - 2}...a_{1}$, such as $a_n = a_{n-1} + a_{n-2}$(fibonacci sequence).
Solution
Number sequence can be corresponded with array in programming language such as C++. If you find the recursive relationship among number sequence, you can write traversal code using for
loop to get the answer.
Examples
- 509.fibonacci-number
- 70.climbing-stairs
- 746.min-cost-climbing-stairs
- 343.integer-break
- 62.unique-paths
- 63.unique-paths-ii