Summary of Dynamic Planning Backpack Classes
1. Fiborachi
thinking
(1) dp[i] Fibolacci number i, I is the number I I
(2) Recursive formula dp[i]=dp[i-1]+dp[i+1]
3. Initialize the first two 0 and 1
(4) Traversal order is from front to back
Examples
The problem here is that the value is too large and requires redundancy of 1000000007.
class Solution {
public int fib(int n) { ...
Posted by shinichi_nguyen on Sat, 16 Oct 2021 18:13:47 +0200
Dynamic programming (DP) algorithm problem 1
Problem description and status definition
Digital triangle problem. There is a triangle composed of non negative integers. There is only one number in the first row. Except for the lowest row, there are one number at the lower left and right of each number, as shown in the figure. Starting from the number in the first line, you can go dow ...
Posted by ReDucTor on Sun, 10 Oct 2021 09:34:08 +0200
Dynamic programming, backtracking and greedy algorithm to solve the change problem (minimum number of sheets payment problem) (JavaScript Implementation)
1. Background requirements:
We have three kinds of coins with different denominations, 11 yuan, 5 yuan and 1 yuan (there must be). We have to pay 15 yuan (integer). How many coins do we need at least?
At least 3 coins (3 5 yuan coins).
2. Realization of dynamic programming
This problem should be fully suitable for dynamic programming ...
Posted by kousalya on Thu, 30 Sep 2021 19:54:50 +0200
Record some questions asked to write in the interview and other favorite questions: the longest palindrome substring + the longest substring without repeated characters + the longest common substring
1. Question 5 of the longest palindrome substring force deduction
Substring: substring must be continuous, which is different from the concept of subsequence
Subsequence:
Where the violent solution can be optimized: palindromes are judged only when the length of the substring is > the current maximum length,
Is there anything that can be ...
Posted by bmyster on Tue, 21 Sep 2021 11:14:33 +0200