Problem
Given an unsorted array of integersnums, return the length of the longest consecutive elements sequence.
You must write an algorithm that runs in O(n) time.
Examples
Constraints
- 0 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9
Tested Python solution for LeetCode 128 with 15 pytest cases. Generate a practice environment with lcpy.
nums, return the length of the longest consecutive elements sequence.
You must write an algorithm that runs in O(n) time.