340. Longest Substring with At Most K Distinct Characters
Given a string, find the length of the longest substring T that contains at mostkdistinct characters.
Example 1:
Example 2:
Thoughts:
keep tracking the size char hashtable d, if oversized, pull the least index value from it and delete the entry, update the low index.
each step compare the current min with (i - low + 1)
Code:
Code: C++ Template
Previous159. Longest Substring with At Most Two Distinct CharactersNext395. Longest Substring with At Least K Repeating Characters
Last updated
Was this helpful?