Saturday, April 27, 2019

1035. Uncrossed Lines

I like to share the link of my discussion post.

Algorithm 1035 Uncrossed lines is here.


I also like to write down my feelings after I wrote and completed the solution after the weekly contest 114. I studied discussion post, and there is a trick to design dynamic programming array size to remove m - 1 out of range edge case, just apply start index = 1 instead of 0. 

Another thing is for me to argue that the cross case is the maximum case if the last number of both arrays are the same. 

Algorithms 3 is a dynamic programming. I have to learn some tip to avoid the edge case. I also asked question about the most popular post the question. The post is here, the question is the following, I did ask some one before more than a year ago, I also wrote a blog about it.

May I ask you how to argue the following statement is correct?
dp[i][j] = 1 + dp[i - 1][j - 1];
The above statement is based on the fact that dp[i - 1][j] <= 1 + dp[i - 1][j - 1] and dp[i][j -1] <= 1 + dp[i -1][j - 1]. How to reason those two formulas?

Follow up 


May 3, 2019

I got response back from the author.


No comments:

Post a Comment