Problem
Given a string s and an integer k, return the length of the longest substring that contains at most `k` distinct characters.
Example 1
- Input
- s = "eceba", k = 2
- Output
- 3
- Why
- "ece"
Example 2
- Input
- s = "aa", k = 1
- Output
- 2
Example 3
- Input
- s = "abaccc", k = 2
- Output
- 4
- Why
- "accc"
Constraints
1 <= s.length <= 5 * 10^40 <= k <= 50