How to check for substring condition and print one with longer length

@hrishikeshjanjal hey your compare function need some improvement here is your compare function
bool compare(string a,string b)
{
if ( (a==b.substr(0,a.length())))
return b.length()>a.length();
else if((b==a.substr(0,b.length())))
return a.length()>b.length();

   return a<b;

}
write this function this will complete your code.

that worked completely fine.will you also explain me the working inside if/elseif conditon?

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.