class Solution: def maxLength(self , arr: List[int]) -> int: # write code here if len(arr) < 2: return len(arr) windows = {} res = 0 left = -1 for right in range(len(arr)): if arr[right] in windows: left = max(left, windows[arr[right]]) res = max(res, right - left) windows[arr[right]] = right return res
1

相关推荐

点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务