25Longest Substring Without Repeats
Hardsliding windowdictionaries
Write longest_unique(text) that returns the length of the longest substring (a run of consecutive characters) that contains no repeated character.
For "abcabcbb" the answer is 3 ("abc").
Examples
Example 1
>>> longest_unique('abcabcbb') 3
Example 2
>>> longest_unique('bbbbb') 1
Good to know
- The last test uses a long string, so checking every substring will be too slow.
Run examples checks the 2 examples above. Submit runs all 7 tests, including hidden edge cases, and marks the challenge solved.