267. Interleaving String

HardStringString

Given strings s1, s2, and s3, return true if s3 is formed by an interleaving of s1 and s2 (preserving the left-to-right order of each). Input: '"s1", "s2", "s3"'.

Input: '"s1", "s2", "s3"'.

Output: Boolean — true or false.

Examples

Example 1
Input: "aabcc", "dbbca", "aadbbcbcac"
Output: true
Explanation: Valid interleaving.
Example 2
Input: "aabcc", "dbbca", "aadbbbaccc"
Output: false
Explanation: Cannot interleave.
Example 3
Input: "", "", ""
Output: true
Explanation: All empty.

Constraints

Asked by

AmazonMicrosoftAppleBloombergGoogleMeta
Solve this problem in the editor →