Longest Substring with At Most K Distinct Characters
Medium · Arrays & Strings · about 15 minutes
Asked at Google, Meta, Amazon, Microsoft, ByteDance.
Find the longest stretch of consecutive characters in s that is built from k or fewer different characters, and return how long it is.