Given a string s and an integer k, return the length of the longest substring of s that contains at most k distinct characters.
A substring is a contiguous non-empty sequence of characters within a string.
Example 1:
Input: s = "eceba", k = 2
Output: 3Explanation: The substring is "ece" with length 3.
Example 2:
Input: s = "aa", k = 1
Output: 2Explanation: The substring is "aa" with length 2.
Constraints:
1 <= s.length <= 5 * 10^40 <= k <= 50