class Solution {
public:
/**
* max increasing subsequence
* @param arr int整型vector the array
* @return int整型
*/
int MLS(vector<int>& arr) {
// write code here
if(arr.empty()) {
return 0;
}
int longest=1, cnt = 1;
vector<int>dp(arr.size(), 1);
sort(arr.begin(),arr.end());
for(int i=1;i<arr.size();++i){
if (arr[i] == arr[i-1]) {
continue;
}
if (arr[i] - arr[i - 1] == 1) {
cnt ++;
} else {
cnt = 1;
}
longest=max(longest, cnt);
}
return longest;
}
};