
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
A string of only 'a's of length k contains k + 1 choose 2 homogenous substrings.
Split the string into substrings where each substring contains only one letter, and apply the formula on each substring's length.