Only 2 test cases are passing

My code is only passing 2 test cases , doing dry run givins the correct output,

my code:- https://ide.codingblocks.com/s/270437

@D19APPND0003

  1. I thing is you missed case when ans doesn’t exist. You have to to print “No String” In that case. So change line 58 to if(ans.length()==0){ cout<<“No String”<<endl; }
    else { cout << ans; }

  2. Dry run your code on this testcase
    aaaab
    ab
    output should be “ab” but your code is giving “aaab”