The third chapter summarizes the algorithm work

1, the optimal solution of the problem if you can get the optimal solution is derived from the sub-problem, you can first solve the problem of sub-optimal solution, the original problem in the construction of the optimal solution; if sub-problems have more recurring , you can self bottom-up solving the original problem from the final sub-problems step by step. Solution of the problem of sub-issues that need to be repeated several times can be calculated using dynamic programming, the count had previously used an array to store it up, to avoid double counting caused by time and space redundancy.

2、

1 . dp[i][j] = max(dp[i+1][j],dp[i+1][j+1]) + a[i][j];

2 . dp[i] = max(max(dp[i-1] + a[i],a[i]));

3, the first pair to mate and build a programming idea, do not rush to fight Code, first stroke along thinking, multi-exchange, in order to achieve faster and better this code!

Guess you like

Origin www.cnblogs.com/os123/p/11788618.html