Sharing my 20ms C++ solution using hash set
class Solution {\n    public:\n        int longestConsecutive(vector<int>& nums) {\n            unordered_set<int> mySet;\n            for(int i=0; i<nums.size(
    class Solution {\n    public:\n        int longestConsecutive(vector<int>& nums) {\n            unordered_set<int> mySet;\n            for(int i=0; i<nums.size(); i++)\n                mySet.insert(nums[i]);\n                \n            int result = 0;\n            while(mySet.size()>0)\n            {\n                int number = *mySet.begin();\n                int count = 1;\n                mySet.erase(number);\n                int smaller = number-1;\n                int bigger = number+1;\n                while(mySet.count(smaller)>0)\n                {\n                    mySet.erase(smaller);\n                    smaller--;\n                    count++;\n                }\n                while(mySet.count(bigger)>0)\n                {\n                    mySet.erase(bigger);\n                    bigger++;\n                    count++;\n                }\n                \n                result = max(result, count);\n            }\n            \n            return result;\n        }\n    };
['C++']