Editorial's approach is wrong (weak testcases)


I have a testcase on which the following code (Editorial’s code) throws wrong output

int Solution::solve(string A) {
    int i=0,n=A.size(),j=n-1, flag=0;
        if(A[i]==A[j]){i++; j--;}
        else if(A[i]!=A[j] && flag==0){ 
            else  if(A[j-1]==A[i]){j--;}
            else if((j-i)==1){return 1;}
            else{return 0;}
        else if(A[i]!=A[j] && flag==1){ return 0;}
    return 1;

and the testcase is :

output should be 1 but it is giving 0

basically you have to completely check both the cases and that’s not the case with the code



you are correct. thanks for the test case!


Output must be 0 in this test case …as it is not possible to convert this string into a palindrome by deleting only one character


Just remove the aaacbdbc_b_aaa