""" Day 99
Good morning! Here's your coding interview problem for today.

This problem was asked by Microsoft.

Given an unsorted array of integers, find the length of the longest consecutive elements sequence.

For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4.

Your algorithm should run in O(n) complexity."""


def consecutive(a):
    c = []
    a.sort()
    for i in range(len(a)-1):
        if a[i+1] - a[i] == 1:
           c.append(a[i])
        else:
            c.append(a[i])
            break

    return c, len(c)



print(consecutive([100, 4, 200, 2, 1, 3]))