Given a string s and an integer k, return the length of the longest substring that contains at most k distinct characters.
- Sliding Window
- HashMap for Character Frequency
- Edge Case Handling
Input: s = "eceba", k = 2
Output: 3
Explanation: The substring is "ece" with length 3.
Input: s = "aa", k = 1
Output: 2
def length_of_longest_substring_k_distinct(s: str, k: int) -> int:
# Implement your solution here
pass