Given an array shows of integers, return the longest contiguous subarray in which all values are distinct (no repeats within the subarray).
shows: List[int]
List[int]
(the subarray values)
If multiple subarrays have the same maximum length, return the one with the smallest starting index.
shows = [1, 2, 3, 2, 4]
→
[1, 2, 3]
shows = [5, 5, 5]
→
[5]
shows = []
→
[]
O(n)
time.
O(n)
is allowed.