At Stripe, event IDs may arrive out of order. Given an unsorted array of integers nums, return the length of the longest sequence of consecutive integers.
A consecutive sequence contains values that differ by 1, and the elements do not need to appear next to each other in the input array.
nums, a list of integersnumsExample 1
nums = [100, 4, 200, 1, 3, 2]4[1, 2, 3, 4].Example 2
nums = [0, 3, 7, 2, 5, 8, 4, 6, 0, 1]9[0, 1, 2, 3, 4, 5, 6, 7, 8]. Duplicate values do not extend the sequence.0 <= len(nums) <= 10^5-10^9 <= nums[i] <= 10^9O(n) average time0.