97. Interleaving String

time: O(m*n), m is s1 length, n is s2 length

space: O(mn

DFS + memo

1 ms, faster than 99.10% of Java online submissions for Interleaving String.

T: O(mn)

S: O(mn)

or use ||, this one is easy to convert to 1D

1D

T: O(mn)

S: O(n)

Last updated

Was this helpful?