C++ solutions
\nclass Solution {\npublic:\n    int longestConsecutive(vector<int>& nums) {\n        unordered_set<int> s(nums.begin(),nums.end()); // this is faster\n        
```\nclass Solution {\npublic:\n    int longestConsecutive(vector<int>& nums) {\n        unordered_set<int> s(nums.begin(),nums.end()); // this is faster\n        \n        // for(int i = 0; i<nums.size(); i++)\n        // {\n        //     s.insert(nums[i]);\n        // }\n        \n        int longest_sequence = 0;\n        \n        for(int i=0; i<nums.size(); i++)\n        {\n            if(s.find(nums[i] - 1)!=s.end())\n                continue;\n            \n            else\n            {\n                int count = 0;\n                int current_element = nums[i];\n                \n                while(s.find(current_element) != s.end())\n                {\n                    count++;\n                    current_element++;\n                }\n                \n                longest_sequence = max(longest_sequence,count);\n            }\n        }\n        \n        return longest_sequence;\n    }\n};\n```
['C', 'C++']