Search
⌘K

Leetcode 1397. Find All Good Strings

Count the number of length-n lowercase strings lexicographically between s1 and s2 (inclusive) that do not contain the substring evil, returning the result mod 1e9+7. Solve with a DP over positions that tracks lexicographic tightness and the current matched prefix of evil (using a KMP/automaton) to avoid forbidden substrings.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.