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