340 Longest Substring with At Most K Distinct Characters
1. Question
Given a string, find the length of the longest substring T that contains at mostkdistinct characters.
For example, Given s =“eceba”
and k = 2,
T is "ece" which its length is 3.
2. Implementation
(1) Two Pointer + Hash
3. Time & Space Complexity
Two Pointer + Hash: 时间复杂度O(n), 空间复杂度O(1)
Last updated