Sort all the strings ( lexicographically ) but if a string is present completely as a prefix in another string, then string with longer length should come first

one test case gets failed.
what’s wrong in this code?
my code link is here:-
https://ide.geeksforgeeks.org/gT5fNGP7lm

hi, i`ll let u know the problem with your code

@ramesh7050042079pd,
Extremely sorry for the delayed reply, got stuck in some place

so, when i tried submiting your code, i see WA for both test cases.
the problem is with the custom sort function that u wrote
lets say string a , string b is being passed
so if
a is substring of b and size of a is less than b
then b should come first
so in that case return b.size() > a.size()
in case b is the substring of a
and a.size() > b.size()
return a.size() > b.size()

else return a < b
below is the piece of code, which works fine

bool comp(string a,string b)
{
if(a.size() <= b.size() and a==b.substr(0,a.length()))
{return false;}
else if (b.size() <= a.size() and b==a.substr(0,b.length()))
{return true;
}
else
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.