Lcs with 3 strings

My code is giving a long weird answer. Please check for mistakes.

@prashantverma.vn
it was giving garbage value, because dp array was not initialized with zero.
dp[][][] = {0} does not initialise to zero.

int dp[n + 1][m + 1][o + 1] {};  //either do this.
// memset(dp, 0, sizeof(dp));   // or this

I don’t understand why my initialization approach didn’t work. I’ve used this in some previous questions.

@prashantverma.vn
= {0} work only for 1D arrays. You might have used that in one dimensional arrays.

1 Like

I hope I was able to answer your queries. You may close the doubt now, and give suitable feedback:).