Use sliding windows to solve the problem.

First, we use the hash map to store how many character and which character we store currently. Then judge our current hash map is valid or not. If valid, let the head move forward and compare to our current maximum, otherwise let our tail move forward and throw out the tail element at the mean time until our current hash map does not exist duplicate element.

It is straight forward, and the time complexity is O(n), and there are no edge case to handle. So that is it.