C# easy and understanding solution
Approach\nFirstly, we need to catch nonrepeated numbers. That\'s why, we use HashSet. After, in the loop we check previous number of the current number exist or
# Approach\nFirstly, we need to catch nonrepeated numbers. That\'s why, we use HashSet. After, in the loop we check previous number of the current number exist or not in the array. If previous number doesn\'t exist, then we guess that our sequence is starting.\n\n# Complexity\n- Time complexity: O(N)\n\n- Space complexity: O(N)\n\n# Code\n```\npublic class Solution {\n    public int LongestConsecutive(int[] nums) {\n        HashSet<int> set = new HashSet<int>(nums);\n        int maxLength = 0;\n\n        foreach(int num in nums) {\n            if(set.Contains(num - 1)) continue;\n            \n            int length = 0;\n            while(set.Contains(num + length)) length++;\n\n            maxLength = Math.Max(maxLength, length);\n        }\n\n        return maxLength;\n    }\n}\n```
['C#']