Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Lintcode29 Interleaving String solution problem solution

Shulou Source: shulou.com Published: 2022-06-03 05:22:57 10月04日 Update

[topic description]

Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2.

Three strings: S1, S2, S3 are given to determine whether S3 is composed of S1 and S2.

[topic link]

Http://www.lintcode.com/en/problem/interleaving-string/

[topic Analysis]

Dp [I] [j] denotes whether the first I of S1 and the first j of S2 are interleaving string or not.

Initialize first. Traverse S1, initializing all dp [I] [0]

Then iterate through S2 and initialize all dp [0] [j]

If the I + Jmur1 bit of S3 is equal to the I bit of S1, let's see if dp [I-1] [j] is true; isomorphic, and if the i+j-1 bit of S3 is equal to the j bit of S2, then let's see whether dp [I] [Jmur1] is true. As long as either of the two cases is true, dp [I] [j] is true.

[reference answer]

Http://www.jiuzhang.com/solutions/interleaving-string/

Tags: Question three character string situation answer link cross reference question solution Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Linux OPPO Reno macOS