Longest Substring Without Repeating Characters - aloalgo

Longest Substring Without Repeating Characters

Medium

You are given a string s.

Your task is to find the length of the longest substring within s that contains no repeating characters.

Note that:

  • A substring is a contiguous non-empty sequence of characters within a string.

Return the length of the longest substring.

Example 1

Input
"happyday"
Output
4
Explanation:

The longest substring without repeating characters is "pyda", which has a length of 4.

Example 2

Input
"banana"
Output
3
Explanation:

The longest substrings without repeating characters are "ban" and "ana", each with a length of 3.

Example 3

Input
"penpineappleapplepen"
Output
5
Explanation:

The longest substring without repeating characters is "pinea", which has a length of 5.

Loading...
Input
"happyday"
Output
4

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!