题解 | #最长无重复子数组#
最长无重复子数组
https://www.nowcoder.com/practice/b56799ebfd684fb394bd315e89324fb4
class Solution: def maxLength(self , arr: List[int]) -> int: # write code here import collections queue = collections.deque() queue.append(arr[0]) length = 0 for i in range(1, len(arr)): if arr[i] in queue: length = max(length, len(queue)) while arr[i] in queue: queue.popleft() queue.append(arr[i]) return max(length, len(queue))