/3. Longest Substring Without Repeating Characters

3. Longest Substring Without Repeating Characters

Medium
Hash Table38.6% acceptance

Given a string input_str, return the length of the longest contiguous substring that contains no repeated characters.

Example 1

Input: "xyzxyzz"

Output: 3

Explanation: The longest substring without repeating characters is xyz.

Example 2

Input: "aaaaa"

Output: 1

Explanation: The longest substring without repeating characters is a.

Example 3

Input: "abcbde"

Output: 4

Explanation: The longest substring without repeating characters is cbde.

Constraints

  • 0 <= len(input_str) <= 50000
  • input_str consists of English letters, digits, symbols, and spaces
Python (current runtime)

Case 1

Input: "123123456"

Expected: 6

Case 2

Input: "abcdefgabcdefg"

Expected: 7

Case 3

Input: ""

Expected: 0

Case 4

Input: "a b c d e f"

Expected: 7

Case 5

Input: "xyxxyx"

Expected: 2