Longest Substring Without Repeating Characters

Medium · Sliding Window · Hash Table · String · Sliding Window

Problem

Given a string s, return the length of the longest substring with no repeated characters.

A substring is contiguous — "pwke" is a subsequence of "pwwkew", not a substring.

Examples

Input: s = "abcabcbb"
Output: 3

"abc" is the longest window.

Input: s = "bbbbb"
Output: 1

"b".

Input: s = "pwwkew"
Output: 3

"wke". "pwke" is not contiguous.

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…