Loading...
Loading...
Loading...
A keyboard logger records a string of characters. Find the length of the longest stretch in which no character appears twice.
Example 1
Input
abcabcbb
Output
3
abc has length 3.
Example 2
Input
bbbbb
Output
1
Try the problem first. Open one hint at a time.
Keep a window with no repeated characters and the last position of each character.
When a character repeats inside the window, move the left end just past its previous position.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor