 All Problems
Longest Substring Without Repeating Characters
medium
sliding window
hash map
strings
amazon
bloomberg
facebook
google

Given a string s, find the length of the longest substring without repeating characters.

Example 1:

Input: abcabcbb
Output: 3
Explanation: "abc"

Example 2:

Input: bbbbb
Output: 1

Constraints:

  • 0 ≤ s.length ≤ 5 × 10⁴
  • s consists of English letters, digits, symbols, and spaces

Input format: One line — the string.

Output format: Length of the longest substring.

Run to check your code against the sample cases, or submit to run every case