# Leetcode 395- Longest substring with at least K repeating characters

`Note:`

- In every iteration, iterate once from
`start`

to`end`

and mark frequencies. If a letter appears more than once but less than`k`

, do a`DFS`

. - How should we know where to set as the
`beginning`

of our`DFS`

. - Set a var
`tmp`

. It tells us where the last`unqualified`

letter is. - Every time we’ve started an iteration, add
`1`

to tmp. - The tricky part is case like
`aaaaaaaaabbbcccccddddd`

. If you do the above, the result will be`9`

instead of`10`

. It’s because our algo won’t do a search on`cccccddddd`

. - Why is that? Coz we would only start a DFS when
`cuttingPoints.has(s[i])`

. But the whole`cccccddddd`

is qualified, so it won’t invoke a DFS. - As you can see, we need a final check in the end.
`if (tmp < end) dfs(s, tmp, end, k);`

.

Do a last DFS if`tmp`

didn’t hit the end.

`Question:`

Given a string `s`

and an integer `k`

, return the length of the longest substring of `s`

such that the frequency of each character in this substring is greater than or equal to `k`

.

`Example:`

1 | Input: s = "aaabb", k = 3 |

`Code:`

1 | /** |