Longest Consecutive Sequence
Asked in the Written problem-solving round stage. The written round included two coding and logic questions and was non-elimination. Candidates later explained their logic in the Tech+HR round.
Given an unsorted list of integers nums, return the length of the longest sequence of consecutive integers. Values may appear more than once, and the sequence does not need to preserve input order.
Implement longest_consecutive(nums). Return an integer length.
def longest_consecutive(nums):