Doubt in print lcs

what is wrong here?

#include
#include<bits/stdc++.h>
using namespace std;

int main() {

string a,b;
cin>>a>>b;
string h="";
int n1=a.length();
int n2=b.length();
int c[n1+2][n2+2];
for(int i=0;i<=n1;i++)
{
	c[i][0]=0;
}
for(int i=0;i<=n2;i++)
{
	c[0][i]=0;
}
for(int i=1;i<=n1;i++)
{
	for(int j=1;j<=n2;j++)
	{
		if(a[i-1]==b[j-1])
		{
			c[i][j]=c[i-1][j-1]+1;
		}
		else
		{
			c[i][j]=max(c[i-1][j],c[i][j-1]);
		}
	}
}
int i=n1,j=n2;
//cout<<c[n1][n2];
while(i>0 && j>0)
{
	if((c[i-1][j]==c[i][j-1] )&&( c[i][j]==c[i-1][j]))
	i--;
	else if(c[i-1][j]==c[i][j-1])
	{h=a[i-1]+h;
	//cout<<a[i-1]<<endl;
	i--;j--;
	}
	else if(c[i-1][j]>c[i][j-1])
	i--;
	else
	j--;
	//cout<<i<<j<<endl;

}
cout<<h<<"\n";


return 0;

}

@jhashantanu52
while forming the lcs you only need three conditions to check:-
(i) if a[i-1]==b[j-1] -> then add it to the answer string, do i-- and j–.
(ii) if(c[i-1][j]>c[i][j-1])
(iii) (c[i-1][j]<c[i][j-1])

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.