给定三个字符串 s1
、s2
、s3
,请你帮忙验证 s3
是否是由 s1
和 s2
交错 组成的。
两个字符串 s
和 t
交错 的定义与过程如下,其中每个字符串都会被分割成若干 非空
子字符串
:
s = s1 + s2 + ... + sn
t = t1 + t2 + ... + tm
|n - m| <= 1
- 交错 是
s1 + t1 + s2 + t2 + s3 + t3 + ...
或者t1 + s1 + t2 + s2 + t3 + s3 + ...
注意:a + b
意味着字符串 a
和 b
连接
示例 1:
输入:s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac" 输出:true
示例 2:
输入:s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc" 输出:false
示例 3:
输入:s1 = "", s2 = "", s3 = "" 输出:true<iframe allowfullscreen="true" data-mediaembed="bilibili" frameborder="0" id="PTJlaLRk-1716539329902" src="https://player.bilibili.com/player.html?aid=112495088042752"></iframe>
Leetcode 97
(抖音号:708231408)
标签:...,708231408,示例,s3,s2,s1,力扣,抖音,字符串 From: https://blog.csdn.net/gordenflfl/article/details/139178033