Coding

Longest Consecutive Sequence

Determine the length of the longest consecutive elements sequence.

Input: nums = [0,3,7,2,5,8,4,6,0,1]

Output: 9

Explanation: The longest consecutive sequence is 0 through 8 (length 9), utilizing a hash set to check connectivity in linear time.

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions