Given a string s and an integer k, return the length of the longest substring of s that contains at most k distinct characters.
Find longest substring with at most 2 distinct characters
e
0
c
1
2
b
3
a
4
left=0
right=-1
Character Count Map (k=2)
empty
distinct = 0 ≤ k = 2
Window Length:
Max Length:
Pointers
Valid Window
Invalid Window