Interleaving String
Return whether s3 can be formed by interleaving all characters of s1 and s2 while preserving each source string order.
Example 1
s1 = "ab"
s2 = "cd"
s3 = "acbd"trueExplanation
Take a from s1, c from s2, b from s1 and d from s2, preserving each order.
Example 2
s1 = "ab"
s2 = "cd"
s3 = "adbc"falseExplanation
d would precede c from s2, violating its order.
Example 3
s1 = ""
s2 = ""
s3 = ""trueExplanation
Two empty sources form the empty target.
Constraints
- 0 <= len(s1),len(s2) <= 100
- 0 <= len(s3) <= 200
- Strings contain lowercase English letters
Function contract
isInterleaveArguments: json, json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 34 cases, on your device.
"ab""cd""acbd"