Sum
Given a string, find the length of the longest substring T that contains at mostkdistinct characters.
Example 1:
Example 2:
Thoughts:
d: a hash table to record distinct value (through (len(d)).
every iteration compare (i - low + 1) with max value (returned value in the end)
when d is over k, delete the least value entry, set low = min(d.values()) + 1
Code:
Last updated
Was this helpful?