Regex Matching With Grouped Stars
Asked at Amazon · Coding Questions · Difficulty: Hard
Implement a regex matcher over lowercase letters with three features: `.` matches exactly one letter, `*` matches zero or more of the immediately preceding element, and a parenthesised group `(...)` is treated as one element (so a `*` after it repeats the whole group). Groups are never nested, never contain `*`, and are always followed by `*`. For each string in `arr`, return `"YES"` if the whole string matches `regex`, else `"NO"`.
Loading the problem…