Problem: Longest continuous common substring, longest common substring (non-contiguous), longest palindrome (continuous), longest palindrome (can discontinuous), longest increment array, rectangle mosaic most solution
Methods: The above problems are similar and can be solved by dynamic programming.
(1) Longest consecutive common substring:
If A[I]==B[J], dp[i][j]=dp[i-1][j-1]+1;
otherwise, dp[i][j]=0;
(2) longest common substring (non-contiguous):
If A[I]==B[J], dp[i][j]=dp[i-1][j-1]+1;
otherwise, dp[i][j]=dp[i-1][j-1];
(3) Maximum palindrome string (non-continuous):
First, the original string A is reversed to get the new string B, and then the longest common substring (non-contiguous) is used for solving.
(4) The longest continuous palindrome string:
First, the original string A is reversed to get the new string B, and then the longest continuous common substring is used to solve the problem.
(5) The longest continuous increment array:
If a[i]>a[i-1],dp[i]=dp[i-1]+1;
otherwise, dp[i]=0;
(6) Maximum increment array (non-contiguous):
If a[i]>a[i-1],dp[i]=dp[i-1]+1;
otherwise, dp[i]=dp[i-1];
(7) Rectangle set Number:
Sort by the length of the rectangle first (if long, the large row behind);
If A[i].length>a[i-1].length and A[i].width>a[i-1].width, then dp[i]=dp[i-1]+1;
otherwise, dp[i]=dp[i-1];
Longest continuous common substring, longest common substring (non-contiguous), longest palindrome (continuous), longest palindrome (can discontinuous), maximum increment array solution