"hello" has spread 2 − 1 = 1 (l twice, every other letter once).
Given a string text, return the sum of spreads over all of its substrings (contiguous pieces). Equal substrings at different positions are counted separately.text="abb" → 1
Only the substring "abb" has a non-zero spread: b appears twice, a once, so 2 − 1 = 1. "bb" has a single letter, spread 0.
text="xyz" → 0
In every substring each letter occurs exactly once, so the answer is 0.
text="aaba" → 4
text consists of lowercase English letterstext="abb"
1
Run checks the first 3 tests in your browser. Submit checks all 106 tests on the server, hidden ones included.