Challenge 9: Strings Interleaving

Let's write code to find out if a given string is the result of interleaving two other strings

Problem Statement

Give three strings m, n, and p, write a function to find out if p has been formed by interleaving m and n. ‘p’ should be considered to be an interleaved form of m and n if it contains all the letters from m and n in a preserved order.

Input

Three strings.

Output

a boolean.

Sample Input

string m="abd";
string n="cef";
string p="abcdef";

Sample Output

1

Coding Exercise

Take a close look and design a step-by-step algorithm before jumping on to the implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the hint and solution provided in the code tab. Good Luck!

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.