Very simple python3 Solution


#1

def longestConsecutive(self, A):
d = {}
res = 0
for i in A:
d[i] = 1
for i in d:
if (i-1) in d:
if d[i] != d[i-1] + 1:
d[i] = d[i-1] + 1
if (i+1) in d:
if d[i+1] != d[i] + 1:
j = i+1
while j in d:
d[j] = d[j-1] + 1
j += 1