题目:
题解:
func isInterleave(s1 string, s2 string, s3 string) bool {
n, m, t := len(s1), len(s2), len(s3)
if (n + m) != t {
return false
}
f := make([]bool, m + 1)
f[0] = true
for i := 0; i <= n; i++ {
for j := 0; j <= m; j++ {
p := i + j - 1
if i > 0 {
f[j] = f[j] && s1[i-1] == s3[p]
}
if j > 0 {
f[j] = f[j] || f[j-1] && s2[j-1] == s3[p]
}
}
}
return f[m]
}