Skip to content
Onsite

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

Run checks the 3 visible tests, Submit all 11.