Longest Substring Without Repeating Characters

Medium

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

Constraints

  • 0 <= s.length <= 5 * 10^4
  • s consists of English letters, digits, symbols and spaces.

Example

Input:   "abcabcbb"

Expected Output: 3

Edge Cases

  • An empty string. The result should be 0.
  • A string with all unique characters (e.g., "abcdef"). The result is the string's length.
  • A string with all the same characters (e.g., "aaaaa"). The result is 1.
  • Strings containing spaces and symbols, which are treated as regular characters.