ntree.ai
ntree.aiLongest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

mediumsolvedattempted

Given a string s, return the length of the longest substring without repeating characters.

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

Example 1:

Input:  s = "pwwkew"
Output: 3
Explanation: The longest substring without repeating characters is `wke`.

Example 2:

Input:  s = "bbbbb"
Output: 1

Constraints:

  • 0 <= length of s <= 5 * 10^4
  • s consists of English letters, digits, symbols and spaces
def lengthOfLongestSubstring(s: str) -> int:
pass
 

Press Visualise to step through your code.