Password Strength

Given a string, find the strength of that string. The string contains only lowercase letters.
The strength of a string is the sum of the number of distinct characters present in all possible substrings.

Example1:
input = "good"
possible all substrings and count of distinct characters are
g = 1
o = 1
o = 1
d = 1
go = 2
oo = 1
od = 2
goo = 2
ood = 2
good = 3
strength = 1+1+1+1+2+1+2+2+2+3 = 16

Example2:
password = "test"
Output: 19

Example3:
password = "abc"
Output: 10

public long stringStrength(String input);




Get one-to-one training from Google Facebook engineers

Top-notch Professionals

Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.

Customized Private Class

Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.