Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

180. Interleaving String

MediumDay 53 of 60Dynamic Programming

Given strings s1, s2 and s3, return true if s3 can be formed by interleaving s1 and s2. Interleaving means splitting both strings into pieces and merging them while keeping the characters of each string in their original order.

Example 1
Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
Output: true
Example 2
Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"
Output: false
Constraints
  • 0 <= s1.length, s2.length <= 100
  • 0 <= s3.length <= 200
  • All strings have lowercase English letters
Hints
Frequently asked at: Google, Amazon, Microsoft
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min