Write a function to solve a specific algorithmic challenge, explaining your thought process for the Federal Reserve System. Implement longest_consecutive(nums) to return the length of the longest sequence of consecutive integers in an unsorted list, without requiring the values to appear in their original order. The function accepts a list of integers and returns an integer; duplicates do not extend a sequence. Aim for O(n) average time and O(n) auxiliary space.
def longest_consecutive(nums):