A typing tutor looks for practice passages inside a text s: a slice of neighboring letters where every letter that appears in the slice appears at least k times.
Write longestRepeatedSlice(s, k) that returns the length of the longest such slice, or 0 if there is none.
Input: s = "aaabb", k = 3 Output: 3
aaa works; including any b would need three bs.
Input: s = "ababbc", k = 2 Output: 5
ababb has two as and three bs.
0 <= s.length <= 10000s contains lowercase letters only.1 <= k <= 10000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #149 Longest Slice With Every Letter Repeated. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.