Solution using sort() function

bool mycompare(char a,char b)
return a-‘0’<b-‘0’;
int Solution::isInterleave(string A, string B, string C) {
string s=A+B;
return 1;
return 0;

This won’t work because the ordering of the characters are changed when they are sorted.

It will fail for some test cases
A : "bccaa"
B : "bdbcc"
C : "aadbbcbccc"
Answer should be 0 but your code is giving it 1

LeetCode will not tolerate this solution :stuck_out_tongue:

Click here to start solving coding interview questions