题解 | #最长无重复子数组#简单粗暴
最长无重复子数组
https://www.nowcoder.com/practice/b56799ebfd684fb394bd315e89324fb4
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param arr int整型一维数组 the array # @return int整型 # class Solution: def maxLength(self , arr: List[int]) -> int: # write code here i = 0 path = [] res = 0 while i < len(arr): # 若存在相同值,则从path第一位开始剔除,直到不存在相同值为止 while arr[i] in path: path.pop(0) path.append(arr[i]) res = max(res, len(path)) i += 1 return res
叮咚买菜工作强度 246人发布