Write a function to solve a specific algorithmic challenge while sharing your screen and explaining your thought process.
Implement longest_consecutive(nums), which returns the length of the longest sequence of consecutive integers in an unsorted array. Duplicate values must not extend a sequence, and the solution should run in expected O(n) time.
Input is a list of integers. Return an integer length. An empty list returns 0.
def longest_consecutive(nums):