Your question is LeetCode Strings or Arrays. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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):