It passes all the testcases that i can think of. But when i submit it, one shows wrong answer and another testcase show run error. What am i doing wrong?
Whats wrong in this?
hi @PNG_Mayank
for this sample output
3
bat
apple
batman
your output is
batman bat apple
which is definitely wrong
your logic of comparision is not correct
it should look like
bool compare(string s1,string s2){
int i=0;
while(s1[i]==s2[i]&&i<s1.length()-1&&i<s2.length()-1){
i++;
}
if(s1[i]==s2[i]) return true;
return s1<s2;
}