C# solution
\npublic class Solution {\n    public int LongestConsecutive(int[] nums) {\n        \n        HashSet<int> set = new HashSet<int>(nums);\n        \n        int 
```\npublic class Solution {\n    public int LongestConsecutive(int[] nums) {\n        \n        HashSet<int> set = new HashSet<int>(nums);\n        \n        int max = 0;\n        foreach(var num in nums)\n        {\n            if(!set.Contains(num - 1))\n            {\n                int start = num;\n                int len = 1;\n                while(set.Contains(++start))\n                    len++;\n                \n                max = Math.Max(max, len);\n            }\n        }\n        \n        return max;\n    }\n}\n```
[]