128. Longest Consecutive Sequence
Medium
Given an unsorted array of integers nums
, return the length of the longest consecutive elements sequence.
You must write an algorithm that runs in O(n)
time.
Example 1:
Example 2:
Constraints:
0 <= nums.length <= 105
-109 <= nums[i] <= 109
解題
Runtime: 138 ms, faster than 75.35%
Memory Usage: 11.1 MB, less than 45.37%
Last updated