标签:until eating ret ide ati oop hashset int size
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)
#3 Longest substring without repeating characters
标签:until eating ret ide ati oop hashset int size
原文地址:https://www.cnblogs.com/yxcindy/p/9938770.html