interviewmind

Practice room

Call time 00:00Get the app
D
Dana · Interviewer
You
You
Captions

Press Play and Dana asks the question out loud.

Questions7/17

CodingMedium

Longest Substring Without Repeating Characters

Given a string s, return the length of the longest substring in which no character appears more than once.

A substring is a run of characters that sit next to each other in s. Characters picked from different places don’t count.

Example 1

Inputs = "banana"Output3

“ban” has no repeated character, and every longer substring does.

Example 2

Inputs = "aaaa"Output1

Example 3

Inputs = "dvdf"Output3

The answer is “vdf”. When the second d arrives, the run can keep the v rather than start over.

Constraints

  • 0 ≤ s.length ≤ 5 · 10⁴
  • s holds English letters, digits, symbols and spaces

Tab indents. Press Escape, then Tab, to move focus out of the editor.

TypeScriptLn 1, Col 1
Practice room — InterviewMind