to solve a leet code algorithms question
Implement longest_consecutive(nums) to return the length of the longest sequence of consecutive integers in an unsorted array. The solution should run in expected O(n) time and must not depend on sorting.
Input: a list of integers. Output: an integer length.
Example: [100, 4, 200, 1, 3, 2] returns 4, because 1, 2, 3, 4 is the longest sequence.
def longest_consecutive(nums):