Number of Distinct Substrings
MediumP3Coding
Return the number of distinct non-empty substrings of s. Substrings are compared by content, so equal substrings at different positions count once.
Example 1
- Input
- s = "abc"
- Output
- 6
Example 2
- Input
- s = "aaa"
- Output
- 3
Example 3
- Input
- s = "a"
- Output
- 1
Constraints
- 1 <= s.length <= 2000
- 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 12. ⌘Enter runs, ⌘⇧Enter submits.