import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
* max increasing subsequence
* @param arr int整型一维数组 the array
* @return int整型
*/
public int MLS (int[] arr) {
// write code here
// 这里利用排序加双指针
// 注意: 如果在连续的过程中遇见重复的数则要跳过
int max=0;
int n = arr.length;
int left =0;
//排序
Arrays.sort(arr);
while(left<n){
//从i位置开始往后走
int count=1;
int right = left+1;
while(right<n){
if(arr[right]-arr[right-1]==1){
count++;
right++;
}else if(arr[right]-arr[right-1]==0){
//遇到相同的元素直接跳过
right++;
}else{
//更新结果
break;
}
}
max = Math.max(count,max);
left = right;
}
return max;
}
}