0 XP · 0 scenes

Regular Expression Matching

Hard2D DP over prefixes of the string and the pattern
Open on LeetCode ↗

1Try it yourself first

00:00

Think for 20-30 minutes before you open any hint. Being stuck is where the learning happens.

Only for you, saved in this browser. After you see the approach you will compare it with your idea.

2What is being asked

Does pattern p match the whole string s? '.' matches any single letter; 'x*' matches zero or more of x.

How to recognise itThe only tricky symbol is '*': it may repeat the previous symbol zero times (skip two pattern symbols) or one more time (consume a string letter, stay on the same pattern).

3Hint ladder

Take one rung at a time. Stop as soon as the idea clicks.

  1. Hint 1
  2. Hint 2

4The approach

Have you tried the hints? The approach is built as a path from the obvious way to the clever one.

✓After you finish

Confidence