String-dp

3 articles

dsa1 min read

Interleaving String — 2D DP

Check if s3 is formed by interleaving s1 and s2. dp[i][j] = can s3[:i+j] be formed from s1[:i] and s2[:j].

Read →
dsa1 min read

Regular Expression Matching — 2D DP

Match string s against pattern p with . and *. dp[i][j] = does s[:i] match p[:j]. Handle * by matching zero or more of preceding char.

Read →
dsa1 min read

Wildcard Matching — 2D DP

Match string with wildcard pattern: ? matches any char, * matches any sequence. Similar to regex but * matches any sequence (not zero/more of preceding).

Read →