23. Longest Substring Without Repeating Characters

Medium · String

Given a string, find the length of the longest substring that does not contain any repeating characters.

A substring is a contiguous sequence of characters within a string. Characters are case-sensitive.

Examples

Example 1
Input: "abcabcbb"
Output: 3
Explanation: The longest substring without repeating characters is "abc", which has length 3.
Example 2
Input: "bbbbb"
Output: 1
Explanation: The longest substring without repeating characters is "b", which has length 1.

Constraints