‹ DS&A interview · Socratic
DSA · Sliding window · #03

Longest Substring Without Repeating Characters

Module 3 · difficulty 3/5·⏱ 30:00starts on first keystroke

Given a string `s`, return the length of the longest substring without duplicate characters.

Examples
  • s = "abcabcbb" → 3 — "abc"
  • s = "bbbbb" → 1 — "b"
  • s = "pwwkew" → 3 — "wke" — "pwke" is not a substring (not contiguous)
  • s = "" → 0
Constraints
  • · 0 <= s.length <= 5 * 10^4
  • · s consists of English letters, digits, symbols, and spaces.
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.