Loading practice problems…
Loading your practice workspace…
Loading code editor…
8 / 29
Sign in
Algorithms/Sliding Window

Longest Substring Without Repeating Characters

medium30 min

Given a string s, return the length of its longest contiguous substring with no repeated characters.

The substring must use adjacent characters from the original string.

Example 1

Inputs = "abcabcbb"

Output3

The longest substring is "abc".

Example 2

Inputs = "bbbbb"

Output1

Constraints

  • 0 ≤ s.length ≤ 50,000
  • s may contain letters, digits, spaces, and symbols.
Sliding WindowStringsHash Set