text of lowercase English letters. Count its contiguous substrings in which all letters are distinct, so no letter appears twice.
Substrings with the same content at different positions count separately.text="moon" → 6
The pieces m, o, o, n, mo, on qualify, six in all. Anything like moo or longer repeats o.
text="cab" → 6
All letters differ, so every piece works: 3 + 2 + 1 = 6.
text="zzz" → 3
text consists of lowercase English letters onlytext="moon"
6
Run checks the first 3 tests in your browser. Submit checks all 136 tests on the server, hidden ones included.