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

1 answer published. Last candidate submission on Jul 20 2026, 11:19am PDT. Interview question asked to Software Engineers interviewing at Microsoft, ByteDance, Cloudera and other companies. Original question asked: Longest Consecutive Sequence. Question last reported by a candidate interviewing at AppFolio for a Software Engineer interview on Nov 17 2026, 7:26pm PDT.