Longest Substring Without Repeating Characters
MediumP1Coding
Given a string s, return the length of the longest substring that contains no repeated character. A substring is a contiguous part of the string.
Example 1
- Input
- s = "abcabcbb"
- Output
- 3
- Why
- "abc" is the longest.
Example 2
- Input
- s = "bbbbb"
- Output
- 1
Example 3
- Input
- s = "pwwkew"
- Output
- 3
- Why
- "wke" (a subsequence like "pwke" does not count).
Constraints
- 0 <= s.length <= 5 * 10^4
- s may contain letters, digits, symbols and spaces.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.