← Practice · Sliding window

Longest Substring Without Repeating Characters Medium

Given a string s, return the length of the longest substring that contains no repeated characters.

Examples

  • "abcabcbb" -> 3 ("abc")
  • "bbbbb" -> 1

Define a function named lengthOfLongestSubstring in JavaScript.

00:00▶ Visualize

JavaScript · Tab indents · Ctrl/⌘+Enter runs the tests