Longest Substring Without Repeating Characters

MediumStringsSliding Window

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

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

Examples

Input: s = "abcabcbb"
Output: 3
The answer is "abc", with the length of 3.
Input: s = "bbbbb"
Output: 1
The answer is "b", with the length of 1.
Input: s = "pwwkew"
Output: 3
The answer is "wke", with the length of 3.

Constraints

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

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More Sliding Window problems