← Back to Problems
3. Longest Substring Without Repeating Characters
3. Longest Substring Without Repeating Characters
Mediumhash-tablestringsliding-window
Companies: Amazon, Google, Bloomberg, Meta, Apple
Acceptance: 33.8%👍 35210|👎 1543
Description
Given a string s, find the length of the longest substring without repeating characters.
Examples
Input:
s = "abcabcbb"
Output:
3
Explanation:
The answer is "abc", with the length of 3.
Input:
s = "bbbbb"
Output:
1
Explanation:
The answer is "b", with the length of 1.
Input:
s = "pwwkew"
Output:
3
Explanation:
The answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
Constraints
- •
0 <= s.length <= 5 * 104 - •
sconsists of English letters, digits, symbols and spaces.
Hints
Loading...
Run your code to see test results
Test Case 1
Input:
{"s":"abcabcbb"}Expected Output:
3
Test Case 2
Input:
{"s":"bbbbb"}Expected Output:
1
Test Case 3
Input:
{"s":"pwwkew"}Expected Output:
3