-
Sliding window
-
Hashset
-
Loop through every element inside the string. If the current char is not inside the hashset, push the char into the hashset and update the longest value. If the current char is already inside the hashset, change the left boundary of the sliding window until the current char is not inside the hashset.
-
Return the longest value.
-
Time complexity: O(n). Space complexity: O(the size of the hashset)
转载于:https://www.cnblogs.com/yxcindy/p/9938770.html