Https://ide.codingblocks.com/s/193725 LCS problem in dynamic programming

getting run error for one test case

Hi @Faizan-Ali-1395131367301898

You declared dp with wrong sizes. Swap row value of dp with a.length() + 1 and column value with b.length( ) +1 .This will correct the runtime error.

Hope it Helps.

Test case 1 showing wrong answer

In return statement also, return dp[a.length()][b.length()] , You will get correct answer. If our query is resolved, mark this doubt as resolved.

Hope it Helps.

@Faizan-Ali-1395131367301898

If your query is resolved, please mark it as resolved.

Thanks.

@Faizan-Ali-1395131367301898
Please mark your doubt as solved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.