50. Longest Consecutive Sequence
Medium
Given an array that may not be sorted, return the length of the longest sequence of consecutive integers present. Repeated values count only once.
Example 1
Input: nums = [12,4,2,3,9,5,4]
Output: 4
Example 2
Input: nums = [7,7,7]
Output: 1
Constraints
- 0 <= nums.length <= 10000
ArraysHash map
Saved in this browser
Caso 1
nums =
[12,4,2,3,9,5,4]
Expected =
4
Caso 2
nums =
[7,7,7]
Expected =
1
Run checks these 2 cases. Submit runs all 6, including hidden ones.