BugForge
DSA

Longest Session Without Repeats

Mediumsliding windowhash map 00:00

A session is a string of page codes (characters). Return the length of the longest contiguous stretch with no repeated character.

Signature

longestUnique(s: string) → int
Example 1
s = "abcabcbb"
output = 3
'abc' → 3
Example 2
s = "pwwkew"
output = 3
'wke' → 3
Example 3
s = ""
output = 0

Constraints

  • 0 ≤ |s| ≤ 5·10^4
Run checks the examples. Submit runs every hidden test (18, including large inputs that catch slow solutions).