Can you help me with the error? Why am I getting this error?

Can you help me with the error? Why am I getting this error?

hi @sakshi_singhal
refer this -->

Hi @Vaibhav277 I just want to know what went wrong in my code. I don’t want solution.

bool operator()(string s1, string s2)
{
	if(mismatch(s1.begin(),s1.end(),s2.begin(),s2.end()).first == s1.end()) return false;
	else if(mismatch(s2.begin(),s2.end(),s1.begin(),s1.end()).first == s2.end()) return true;
	else s1<s2;
}

kindly explain ur this part of code…

mismatch will take smaller string then larger string and checks if smaller is a part of larger string or not. In the if clause I am considering s1 to be smaller string and then whether it is a subset of s2 or not.

but the error is not in this function, the error is in declaring the sort function which I have used.

@sakshi_singhal
no need to declare class… simply create compare function…
also else s1<s2; here return keyword is missing…
corrected code -->


It’s passing all test cases now…

@sakshi_singhal
I hope it’s clear now… shall I mark this doubt as resolved?

Yes, thanks a lot for helping me out

1 Like

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.