DSA · Strings · #105
Longest Substring Without Repeating Characters
Module 62 · difficulty 3/5·⏱ 30:00starts on first keystroke
Given a string `s`, implement `lengthOfLongestSubstring(s)` that returns the length of the longest substring of `s` that contains no repeating characters. A substring is a contiguous, non-empty sequence of characters within the string. Return `0` for an empty input.
Examples
s = "abcabcbb"→3— The answer is "abc", with length 3.s = "bbbbb"→1— The answer is "b".s = "pwwkew"→3— The answer is "wke". Note "pwke" is a subsequence, not a substring.
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.