题解 | #最长无重复子数组#
最长无重复子数组
https://www.nowcoder.com/practice/b56799ebfd684fb394bd315e89324fb4
class Solution: def maxLength(self , arr: List[int]) -> int: ans , an = [] , set() for i in range(len(arr)): if arr[i] in ans: an.add(len(ans)) x=ans.index(arr[i]) ans = ans[x+1:] if x < len(ans)-1 else [] ans.append(arr[i]) an.add(len(ans)) return max(an)