You are given:
s
consisting of lowercase English letters
k
Return the length of the longest substring of s such that every distinct character in that substring appears at least k times within the substring.
If no such substring exists, return -1.
k <= 1
, the answer is
len(s)
.
k > len(s)
, and repeated characters.
s = "aaabb", k = 3
→ longest valid substring is
"aaa"
→ return
3
.