AmazonOA #186
Find Password Strength
Estimated HardJudge-ready
For every non-empty contiguous substring, count its distinct characters, then add up the counts of the substrings at all positions. The source's aa example left out aa itself; this site corrects it to 3 and does not adopt the "number of characters that appear exactly once" definition.
Input
One line containing a lowercase password string. This site uses length 1..100000.
Output
Output a single integer, the answer.
Example 1
Input:
good
Output:
16
Example 2
Input:
aa
Output:
3
Example 3
Input:
abc
Output:
10
Example notes
The answers are 16, 3 and 10.
Editorial
Loading solution…