Loading...
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
You must write an algorithm that runs in O(n) time.
100,4,200,1,3,2
4
{100, 4, 200, 1, 3, 2}num - 1 is not in the set)1 is a sequence start and its consecutive numbers are 2, 3, and 4, so the sequence length is 4