Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Interleaving String

Medium

Topics
StringDynamic Programming

Given strings s1, s2, and s3, return true if s3 is formed by an interleaving of s1 and s2 (preserving the order of each).

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
  • s3.length == s1.length + s2.length
  • Inputs are lowercase letters.
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access