Simple C++ two solution O(N) & N(NLOGN)
(I) SORT THE VECTOR THEN COMPARE EACH VALUE.\n-----------------------------------O(NLOGN), O(1)-----------------------------------------------------------------
(I) SORT THE VECTOR THEN COMPARE EACH VALUE.\n-----------------------------------O(NLOGN), O(1)----------------------------------------------------------------------\n\n```\nint longestConsecutive(vector<int>& nums) {\n        if(nums.size() == 0)\n            return 0;\n        sort(nums.begin(), nums.end());\n        \n        int cus = 1;\n        int maxs = 1;\n        \n        for(int i=1;i<nums.size();i++){\n            if(nums[i]!=nums[i-1]){\n                if(nums[i] == nums[i-1]+1){\n                    cus+=1;\n            }\n            else{\n                maxs = max(maxs,cus);\n                cus = 1;\n            }\n        }\n       }\n        return max(maxs,cus);\n    }\n```\n\n(II) MAKING USE OF THE HASH SET \n----------------------------------O(N), O(N) --------------------------------------------------------------------------------\n\n```\nint longestConsecutive(vector<int>& nums) {\n        if(nums.size() == 0)\n            return 0;\n        unordered_set<int> s;\n        for(int i: nums)\n            s.insert(i);\n        int ans = 0;\n        \n        for(int i=0;i<nums.size();i++){\n            //minimum element to be searched for the purpose of comparing the next +1 value\n            if(s.find(nums[i]-1) == s.end()){\n                int j = nums[i]; // current value\n                // next values while true do j++\n                while(s.find(j)!=s.end())\n                    j++;\n                // max of previous ans and j - nums[i](-> smallest value)\n                ans = max(ans,j-nums[i]);\n            }\n        }\n        return ans;\n    }\n```\n\nDON\'T FORGET TO UPVOTE. IF YOU UNDERSTOOD BOTH THE APPROACHES.
['C', 'C++']