How to solve the following problem. Find the sum of the number of distinct characters in all the distinct substrings of S. 1<=|S|<=100000. S="aabb"
Set of distinct sub-strings of "aabb" = {a,b,aa,ab,bb,aab,abb,aabb} sum = 1 + 1 + 1 + 2 + 1 + 2 + 2 + 2 = 12.
Thanks!