Easy Python Solution
\n# Code\n\nclass Solution:\n    def longestConsecutive(self, nums: List[int]) -> int:\n        num_set = set(nums)\n        max_length = 0\n        \n        f
\n# Code\n```\nclass Solution:\n    def longestConsecutive(self, nums: List[int]) -> int:\n        num_set = set(nums)\n        max_length = 0\n        \n        for num in num_set:\n            if num - 1 not in num_set:\n                cur_num = num\n                cur_length = 1\n                \n                while cur_num + 1 in num_set:\n                    cur_num += 1\n                    cur_length += 1\n                \n                max_length = max(max_length, cur_length)\n        \n        return max_length\n\n```
['Python3']