```
a b a b b c d b a, k=2
```

First, we consider the situation that only one kind of char satisfies the condition, which is to say,

the same letter needs to occur at least k times to be effective, and in the above example, only the substring "bb" satisfies the condition, thus in this loop, we need to update the result to 2.

Here is what we do in this loop:

We use two pointers to specify the start and the end position of the effective substring. The end pointer marks the char that we're exploring.

The start pointer moves right when the end pointer points to the second kind of char, and it wil continue go right until the string between start and end contains only the char that's the same as the end char. and we calculate (end-start) and compare it with k, when (end-start) > k, we update the result with max(result, (end-start)).

e.x.,

a b a b b c d b a

s

e

a b a b b c d b a

s

e

end - start= 2, and we can update the result to 2, then we continue explore.

a b a b b c d b a

s

e

a b a b b c d b a

s

e

a b a b b c d b a

s

e

a b a b b c d b a

s

e

We finish the exploring of finding the longest substring containing only one kind of char and get the result of 2.