Notice Period

Longest Fresh Streak

medium

A radio DJ never wants to repeat a song within a single uninterrupted set. Her playlist history is a string tracks where each character is a song code.

Return the length of the longest contiguous run of tracks in which no song code appears twice.

Example 1
in tracks = "abcabcbb"
out 3
"abc" is the longest repeat-free run.
Example 2
in tracks = "bbbbb"
out 1
Example 3
in tracks = "pwwkew"
out 3
"wke" — note it must be contiguous, so "pwke" does not count.
Constraints
  • · 0 <= len(tracks) <= 2000
  • · tracks consists of printable ASCII characters
similar problem on LeetCode ↗
solution.pyloading python…
test results
Hit ▶ Run to test your code against the visible cases.