Longest Consecutive Sequence
Updated Feb 24, 2026
Problem
Return length of the longest consecutive elements sequence.
Constraints
0 <= nums.length <= 10^5
Examples
Example 1
Input:
{"nums": [100, 4, 200, 1, 3, 2]}
Output:
4
Function Signature
def longestConsecutive(self, nums: list[int]) -> int
How to Submit
Implement a Solution class with a longestConsecutive method.
Your method will be called with the input parameters and should return the answer.