Available question text
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.
Related questions
Continue with questions that share topics or the same question type.
- Find All Good Indices
Coding
- Count Ways To Build Good Strings
Coding
- Find a Good Subset of the Matrix
Coding
- Find All Anagrams in a String
Coding · Hash Table · Sliding Window · String
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1397. Find All Good Strings
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source