my code is running perfectly fine for sample test case but is giving wrong answer for the other test cases. what is wrong in the code?
String sorting problem
you can just modify your compare function like this and remove your issubstring() function
bool myCompare(string a, string b) {
if (a.find(b)==0 || b.find(a)==0)
return a.length() > b.length();
return a < b;
}
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.