Zero To DSAZero To DSA
Privacy Policy
Product of Array Except SelfValid Palindrome

Longest Substring Without Repeating Characters

medium
Time: O(n)
Space: O(k)

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

Constraints

  • 0 <= s.length <= 5 * 10⁴

Examples

Input: s = "abcabcbb"
Output: 3
"abc" has length 3.
Input: s = "bbbbb"
Output: 1
"b" has length 1.
Input: s = "pwwkew"
Output: 3
"wke" has length 3.