My code is not passing all test cases plzz help me to make the corrections will be very thankful
Problem :
my code >>>
My code is not passing all test cases plzz help me to make the corrections will be very thankful
Problem :
my code >>>
BHAIYA it would have been very nice if u put comments on edit now I am having little doubts
on i==0 && j==0 break condition what if strin1[0] and string2[0] are part of LCS and thus we need to append them only once but loops below will append twice !!! HELP EXPLAIN THIS A BIT MORE and plzz put comments in code where u made edits
while(i>=0){
ans.push_back(str1[i]);
i--;
}
while(j>=0){
ans.push_back(str2[j]);
j--;
}
I mean why taking these cases separately
else if(i==0){
ans.push_back(str2[j]);
j--;
}
else if(j==0){
ans.push_back(str1[i]);
i--;
}
The thing is that one of them can be 0 and other is not.
Let’s say i = 0 and j!=0, now you are trying to access index i-1 in this case, which was resulting in segmentation fault. So in order to avoid that I added extra checks.
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.