Search
⌘K

Leetcode 1180. Count Substrings with Only One Distinct Letter

Count the number of substrings in a string that consist of a single repeated character (i.e., contain only one distinct letter). This is typically solved by scanning for consecutive runs of the same character and summing the number of substrings each run contributes (k*(k+1)/2) in O(n) time.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.