Longest Substring Without Repeating Characters
medium · sliding window
You are given a string `s`. Find the length of the longest substring (a contiguous block of characters) that contains no repeating character. Return that length as an integer.
Input: `s` (a string).
Output: the length of the longest substring with all distinct characters.
Example: s = "abcabcbb" -> 3, because "abc" is the longest substring without repeats.
Starter code
def length_of_longest_substring(s: str) -> int:
"""Return the length of the longest substring with no repeating characters."""
pass
Enable JavaScript to edit this code and run the hidden tests in your browser. Each test has a five-second execution limit. Your drafts and solved progress stay in this browser.
Return to the Python compiler