0003. Longest Substring Without Repeating Characters
Medium | String + Two Pointer | 36 ms (99.77%), 13.7 MB (73.48%)
Source: LeetCode - Longest Substring Without Repeating Characters GitHub: Solution / Performance
Given a string s
, find the length of the longest substring without repeating characters.
Instead of checking each possible substring in the input string:
We could use two pointers to form a sliding window to get the longest substring.
Regarding the repeating characters, we could use the hash table (dict or set in Python) to record each character in the current sliding window.
Last updated