Longest Substring with At Most K Distinct Characters (LeetCode 340).
Asked in the Coding round 2 stage. It was a 45-minute coding round; the candidate solved it.
Given a string s and integer k, return the length of the longest substring containing at most k distinct characters. A substring must be contiguous.
Function: def length_of_longest_substring_k_distinct(s, k):
Return an integer. If s is empty or k is zero, return 0.
def length_of_longest_substring_k_distinct(s, k):