Loading...
Loading...
Loading...
A form checker reads a word of lowercase letters. Print the length of the longest piece of it in which no letter appears twice.
Example 1
Input
abcabcbb
Output
3
The piece "abc" has length 3, and no longer piece has all different letters.
Example 2
Input
pwwkew
Output
3
The piece "wke" has length 3.
Try the problem first. Open one hint at a time.
Keep the letters of the current piece in a set. When the new letter is already in it, drop letters from the left.
Or store the last position of each letter and jump left past it.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor