JJobsMoi
Netflix

Longest Substring Without Repeating Characters

Codingmedium

Problem

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

A substring is a contiguous sequence of characters within a string.

Examples

Example 1:

Input: s = "zxyzxyz"

Output: 3

Explanation:

The string "xyz" is the longest without duplicate characters.

Example 2:

Input: s = "xxxx"

Output: 1

Constraints

  • 0 <= s.length <= 1000
  • s may consist of printable ASCII characters.

Solution

Loading editor…

Sign in to get AI feedback on your answer. Your work is saved while you do.

Sign in to evaluate