Count Substrings of Prime Length
EasyP3Coding
Count the substrings of s whose length is a prime number. Substrings are counted by position, so equal substrings at different positions count separately.
Example 1
- Input
- s = "abc"
- Output
- 3
Example 2
- Input
- s = "a"
- Output
- 0
Example 3
- Input
- s = ""
- Output
- 0
Constraints
- 0 <= s.length <= 5000
- s consists of lowercase letters.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 11. ⌘Enter runs, ⌘⇧Enter submits.