Microsoft Teams mobile can group message text into compact previews. Given a message string s and an integer k, return the length of the longest contiguous substring containing at most k distinct characters.
Characters are case-sensitive, and spaces and punctuation count as characters. Return 0 when k is 0 or the string is empty.
s and an integer k.s with at most k distinct characters.def longest_k_distinct(s, k):