Loading
Loading
A session recorder stores the sequence of pages a visitor opened. Analysts want the longest unbroken stretch in which no page was opened twice.
Return the length of that stretch.
pages = "abcabcbb"[a]bcabcbbwindow a — length 1[abc]abcbbwindow abc — length 3a[bca]bcbbsecond a forces the left edge past the first…no window ever exceeds 33Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n) time · O(min(n, alphabet)) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
"abc" is the longest distinct stretch.
Example 2
Example 3
"wke" — note that "pwke" is not contiguous.