Skip to interview prep
Apexed

37. Longest Substring Without Repeating Characters

MediumSliding window

Return the length of the longest substring of s that contains no repeated characters.

Example 1

Input: s = "abcabcbb"
Output: 3
Explanation: "abc"

Example 2

Input: s = "pwwkew"
Output: 3
Explanation: "wke"

Constraints

  • 0 ≤ s.length ≤ 5 × 10⁴

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 6 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Longest Substring Without Repeating Characters — coding interview practice — Apexed