String sort problem

sir i wrote the code for this question and it is also giving correct answer but when i submit it then it shows that one test case is not passed. i m providing u the link of my code here -

please somebody look into my code and tell me what have i done wrong???

you should only return by length when one string is prefix of the other, you are just checking the first element for example in case of bat and bztman your code would give wrong answer.

1 Like

thank u @keshavgupta0103 sir. now it is working fine.

sir i have one more doubt not in this question but in painter problem question. i wrote the code for that question nd it is also working correctly but when i submit that code then it only passes only 1 test case. can u please tell me what have i done wrong in this question too?

link of my code is -