Ezvor

1180. Count Substrings with Only One Distinct Letter

EasyMath Preparing judge… LeetCode
MathString

Hints

Hint 1
What if we divide the string into substrings containing only one distinct character with maximal lengths?
Hint 2
Now that you have sub-strings with only one distinct character, Try to come up with a formula that counts the number of its sub-strings.
Hint 3
Alternatively, Observe that the constraints are small so you can use brute force.