text function lengthOfLongestSubstring(s): left = 0 maxLen = 0 seen = empty hash set for right from 0 to length(s) - 1: // Shrink window until s[right] is not in window while s[right] in seen: seen.remove(s[left]) left++ seen.add(s[right]) maxLen = max(maxLen, right - left + 1) return maxLen Time complexity: . Each character is added and removed from the set at most once. Space complexity: where is the alphabet size.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/two-pointers-sliding-window/longest-substring-without-repeating-pseudocode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████