You are given an unsorted array of integers nums, find and return the length of the longest sequence of consecutive numbers.
[100, 4, 200, 1, 3, 2]
4
The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.
[0, 3, 7, 2, 5, 8, 4, 6, 0, 1]
9
The longest consecutive elements sequence is [0, 1, 2, 3, 4, 5, 6, 7, 8]. Therefore its length is 9.
[]
0
An empty array has no sequences, so the length is 0.
[100, 4, 200, 1, 3, 2]
4