Code
class Solution(object):
def longestConsecutive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
hash_set = set(nums)
res = 0
for n in nums:
if (n-1) not in hash_set:
length = 0
while (n+length) in hash_set:
length += 1
res = max(length, res)
return res