import java.util.*;
public class Solution {
/**
*
* @param arr int整型一维数组 the array
* @return int整型
*/
public int maxLength (int[] arr) {
// write code here
ArrayList<Integer> temp = new ArrayList<>();
int max = 0;
ArrayList<Integer> maxList = new ArrayList<>();
for(int i = 0;i<arr.length;i++){
if(temp.contains(arr[i])){
while(true){
Integer next = temp.remove(0);
if(next == arr[i]){
break;
}
}
}
temp.add(arr[i]);
max = Math.max(max,temp.size());
}
return max;
}
}


京公网安备 11010502036488号