counter to keep track of the frequency of each character within the window.left to 0 and max_size to 0.right from 0 to the length of the string s minus 1.
a. Increment the frequency of s[right] in counter.
b. While the number of distinct characters in counter is greater than k, increment left and decrement the frequency of s[left] in counter. If the frequency becomes 0, remove the character from counter.
c. Update max_size to the maximum of its current value and the size of the current window (right - left + 1).max_size as the result.