Help debug dynamic programming problem!

Правка en3, от lvisbl_, 2024-11-01 02:22:58

Recently, I have encounter this dynamic programming problem and I can not debug where I have problem, I used forward DP style and I have checked the transition and base case. Please help me to look at it, I'm so frustrating. Thank in advance.

Problem link: leetcode

My code:

code

Updated fix my problem: my for loop only run until i = n, but the final dp state which is dp[n + 1][m + 1] can be reached from dp[n + 1][m] => My for loop should run till n + 1 so this relaxation can happen.

fixed
Теги dynamic programming

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский lvisbl_ 2024-11-01 02:22:58 55
en2 Английский lvisbl_ 2024-11-01 02:22:16 1318
en1 Английский lvisbl_ 2024-10-31 22:45:38 1524 Initial revision (published)