题解 | #最长无重复子数组#
最长无重复子数组
https://www.nowcoder.com/practice/b56799ebfd684fb394bd315e89324fb4
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param arr int整型一维数组 the array # @return int整型 from typing import List class Solution: def maxLength(self , arr: List[int]) -> int: # write code here l = 0 r = 0 res = [] best_res = [] while r < len(arr): res = arr[l:r+1] while res.count(arr[r]) > 1: l += 1 res = arr[l:r+1] if len(res) > len(best_res): best_res = res[:] r += 1 return len(best_res)