✅💯🔥Simple Code🚀📌|| 🔥✔️Easy to understand🎯 || 🎓🧠Beats 100%🔥|| Beginner friendly💀💯
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n//           //////////////////ATISHAY\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\           \\\\\n//           \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\JAIN//////////////////           \\\\\nclass Solution {\n    public int longestConsecutive(int[] nums) {\n        int n=nums.length;\n        if(n==0){\n            return 0;\n        }\n        Arrays.sort(nums);\n        int count=1, maxi=1;\n        for(int i=0;i<n-1;i++){\n            if(nums[i]==nums[i+1]){\n                continue;\n            }\n            if(nums[i+1]-nums[i]==1){\n                count++;\n            }else{\n                maxi=Math.max(maxi, count);\n                count=1;\n            }\n        }\n        maxi=Math.max(maxi, count);\n        return maxi;\n    }\n}\n```\n![7be995b4-0cf4-4fa3-b48b-8086738ea4ba_1699897744.9062278.jpeg](https://assets.leetcode.com/users/images/fe5117c9-43b1-4ec8-8979-20c4c7f78d98_1721303757.4674635.jpeg)
['Array', 'Hash Table', 'Union Find', 'C', 'Python', 'C++', 'Java']