class Solution { public: int MLS(vector<int>& arr) { // write code here if(arr.empty()) return 0; int longest=1; int count=1; sort(arr.begin(),arr.end()); for(int i=1;i<arr.size();++i){ if(arr.at(i)==arr.at(i-1)) continue; if(arr.at(i)-arr.at(i-1)==1) ++count; else count=1; longest=max(longest,count); } return longest; } };