Applied AI Engineer (LLM) coding learning path Level 2 This level · 7 of 31

Longest Substring Without Repeating Characters

Medium Sliding window String

Problem

Given a string, return the length of the longest substring that contains no repeated character.

Original: LeetCode 3: Longest Substring Without Repeating Characters.

Examples

Example 1

Input`s = "abcabcbb"`
Output`3`

Example 2

Input`s = "bbbbb"`
Output`1`

Example 3

Input`s = "pwwkew"`
Output`3`

Example 4

Input`s = ""`
Output`0`

Constraints

  • 0 <= s.length <= 10^5
  • s consists of English letters, digits, symbols and spaces.

Hints

Solution

Tried it yourself? The approach, complexity, and code stay hidden until you choose.

Sources (3)
  1. LeetCode 3: Longest Substring Without Repeating Charactersleetcode.com
  2. Java SE 17 API: HashMapdocs.oracle.com
  3. LeetCode Discuss: Microsoft SDE-2 recent questions 2025 (candidate reports, secondary)leetcode.com
Previous
Next