Longest Substring Without Repeating Characters

Sliding Window, problem 3 of 7

Longest Substring Without Repeating Characters

Medium

LC #3

stringhash mapvariable window

Not attempted yet

Given a string s, return the length of the longest substring (a contiguous run of characters) in which no character appears more than once.

Example 1

Input: s = "abcabcbb"
Output: 3
"abc" is the longest.

Example 2

Input: s = "bbbbb"
Output: 1

Example 3

Input: s = "pwwkew"
Output: 3
"wke". "pwke" is not contiguous.

Constraints

  • 0 ≤ len(s) ≤ 5·10^4
  • s may contain any characters (letters, digits, symbols, spaces).

Python

Loading draft…

Test results

9 tests available

No results yet

Run tests your code against the examples; Submit runs the hidden tests too.

3 examples, 6 hidden

Run examples, then submit all tests.