❤️🎶Longest Consecutive Sequence ❤️🎶|| Easy method || O(nlogn) ||
\nclass Solution {\npublic:\n    int longestConsecutive(vector<int>& nums)\n    {\n        \n        \n\n        map<int,int>mp;\n        \n        int n=nums.s
```\nclass Solution {\npublic:\n    int longestConsecutive(vector<int>& nums)\n    {\n        \n        \n\n        map<int,int>mp;\n        \n        int n=nums.size();\n        \n        for(int i=0;i<n;i++)\n        {\n            mp[nums[i]]++;\n        }\n        \n        nums.clear();\n        \n        for(auto it=mp.begin();it!=mp.end();it++)\n        {\n            nums.push_back(it->first);\n        }\n        \n        if(n==0)\n        {\n            return 0;\n        }\n        \n        sort(nums.begin(),nums.end());\n        \n        int len=1;\n        int maxx=INT_MIN;\n        \n        for(int i=0;i<nums.size()-1;i++)\n        {\n            int value=nums[i+1]-nums[i];\n            \n            if(value==1)\n            {\n                len++;\n            }\n            else\n            {\n                maxx=max(maxx,len);\n                len=1;\n            }\n        }\n        \n        maxx=max(maxx,len);\n        \n        return maxx;\n    } \n        \n};\n\n```
[]