题解 | #最长无重复子数组#
最长无重复子数组
http://www.nowcoder.com/practice/b56799ebfd684fb394bd315e89324fb4
#
#
# @param arr int整型一维数组 the array
# @return int整型
#
class Solution:
def maxLength(self , arr ):
# write code here
ans=0
if len(arr)<=1:
return len(arr)
star,end=0,0
while(end<len(arr)-1):
for i in range(end,star-1,-1):
if arr[i]==arr[end+1]:
ans=max(end-star+1,ans)
star=i+1
end=end+1
else:
ans=max(end-star+1,ans)
return ans