Simple O(n) with Explanation ✔️✔️💯✅
Approach\n\n1. HashSet: It\'s like a special box that can only hold unique numbers.\n2. Adding Numbers: It puts all the numbers from the list into this special 
# Approach\n\n1. HashSet: It\'s like a special box that can only hold unique numbers.\n2. Adding Numbers: It puts all the numbers from the list into this special box.\n3.Counter: It gets ready to count something.\nLoop 1:\n- For Each Number in the special box:\n    - If the number one less than this one isn\'t in the box:\n        - Start counting from this number and keep going up until the next number isn\'t in the box.\n        - Keep track of how many numbers you counted.\n    - Remember the longest chain you found.\n\n4.Result: Tell me how long the longest chain you found is.\n\n\n# Code\n```\nclass Solution {\n    public int longestConsecutive(int[] nums) {\n        \n        HashSet<Integer> hs = new HashSet<>();\n\n        for (int i: nums){\n            hs.add(i);\n        }\n        int c =0;\n\n        for (int x:hs){\n            if(!hs.contains(x-1)){\n                int y = x+1;\n                while(hs.contains(y)){\n                    y++;\n                }\n                c= Math.max(c,y-x);\n            }\n        }\n        return c;\n    }\n}\n```
['Java']