Solution without DP O(nlogn) and O(1)


    int Solution::isInterleave(string A, string B, string C) {
        string s = A + B;
        sort(s.begin(), s.end());
        sort(C.begin(), C.end());
        return s == C;
    }

Turns out the test cases at InterviewBit aren’t clever enough to reject this solution

Wrong solution. This solution will always return true when characters in string a and b are equal to characters of string c.

test case : A=“abc” , B=“az”, C=“aczba”
expected output: 0
your code returns: 1

Click here to start solving coding interview questions