Very simple C++ soln
\n        \n        int longestConsecutive(vector& nums) {\n\t\t\tif(nums.size()==0) return 0;\n\t\t\tif(nums.size()==1) return 1;\n\t\t\tsort(nums.begin(),nums
\n        \n        int longestConsecutive(vector<int>& nums) {\n\t\t\tif(nums.size()==0) return 0;\n\t\t\tif(nums.size()==1) return 1;\n\t\t\tsort(nums.begin(),nums.end());\n\t\t\tint len=1,maxLen=1;\n        \n\t\t\tfor(int i=0;i<nums.size()-1;i++){\n\t\t\t  if(abs(nums[i+1]-nums[i]) == 1){\n\t\t\t\t len++;\n\t\t\t  }\n\t\t\t  else if(nums[i]==nums[i+1]){\n\t\t\t   continue;\n\t\t\t  }\n\t\t\t  else{\n\t\t\t\t  len=1;         \n\t\t\t   }\n\t\t\t   maxLen=max(len,maxLen); \n\t\t\t}\n\t\t\treturn maxLen;\n\t\t}\n\'\'\'
['Sorting', 'C++']