# Longest Substring with At Most K Distinct Characters
Given a string `s` and an integer `k`, return the length of the longest substring of `s` that contains at most `k` distinct characters.
This is the variable-window half of the two-pointer/sliding-window pattern taught in Module 0 — grow the window while it stays valid, shrink it from the left the moment it isn't.
**Example:** `s="eceba", k=2` -> `3` (window `"ece"`).
Target complexity: O(N) time, O(k) space.