less than 1 minute read

Given a lowercase alphabet string s, return the total number of substrings that contain one unique character.

Constraints

  • n ≤ 10,000 where n is the length of s.

https://binarysearch.com/problems/Number-of-Unique-Character-Substrings

Examples

Example 1

Input

  • s = aab

Output

  • answer = 4

Explanation

These substrings have one unique character: ["a", "a", "aa", "b"]

Solution

Leave a comment