Loading...
Loading...
Loading...
Given a string of lowercase letters, find the length of the longest stretch of consecutive characters in which no letter repeats.
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 start and a dictionary of the last position of each letter.
When a letter repeats inside the window, move the start just after its last position.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor