Longest increasing subsequence(LIS) series
Introduction
Fibonacci
Longest Ascending subarray
Maximal product when cutting rope
Dictionary Problem
Jump Game
DP本质:induction是从个例到个性(规律)的推演过程
解题过程
Recursion + Memoization
Dynamic Programming
核心思想类似于数学归纳法
把一个大问题的解决方案用比他小的问题
Subarray: 连续contiguous elements in an array
Subsequence:不一定连续 not necessarily contiguous(can jump)
base case: only one element M[0] = 1
induction rule: M[i] represents the max length of the ascending subarray with the range of [0, i](including the i-th element)
return: global max
TC: O(n)
SC: O(n) → Optimize to O(1)
Solution 1: DFS (recursion)
solution 2: DP(左大段 + 右小段思想)
Base case:M[0] = invalid, M[1] = invalid
induction rule: M[i] represents the maximal product of
M[i] = max(max(j, M[j]) * (i -j) where 1 < = j < i
TC: O(n^2)
SC: O(n)
TC: O(n^3)
SC: O(n)
<aside> 📌 SUMMARY:Linear scan and look back
</aside>
小青蛙问题
Minimum number of Jumps
Longest Sum of a Subarray
<aside> 📌 SUMMARY:
</aside>