AAlgoLab
ALG-M002MediumSliding Window

Longest Unique-Character Window

Return the maximum length of a contiguous substring that contains no repeated characters. An empty string returns zero.

Contract

input text: string
return integer

Constraints

  • • 0 <= text length <= 100000

Examples

Example 1
text = "abcabcbb"
→ 3
Example 2
text = "pwwkew"
→ 3

5 judge tests (2 shown above). Target complexity: O(n) average.