Longest Substring Without Repeating Characters

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

A substring is a contiguous sequence of characters within a string. Return the maximum possible length among all substrings of s that contain no duplicate characters.

Example 1
Inputs = "abcabcbb"
Output3
The longest substrings without repeating characters are abc, bca, cab, and abc, each with length 3.
Example 2
Inputs = "pwwkew"
Output3
The longest substring without repeating characters is wke, which has length 3.

Constraints

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

Asked at 110 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate