Whats wrong with my code its not passing 1 test case

@sarthaksingh hey sarthak your code is not working for the large input this is because of the fact you have done mistake in the while loop.
int index = dp[m][n];
char lcs[index+1];
lcs[index] = ’ ';
int i = m, j = n;
while (i > 0 && j > 0)
{
if (a[i-1] == b[j-1])
{

      lcs[index-1] = a[i-1]; 
      i--; j--; index--;    
  } 

  else if (dp[i-1][j] > dp[i][j-1]) 
     i--; 
  else
     j--; 

}

cout << lcs;

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.