Longest Consecutive Sequence

Medium · Hashing · about 20 minutes

Asked at Google, Amazon, Meta.

nums is unsorted. Using its values, how long a streak of back-to-back integers (like 4, 5, 6, 7) can you assemble? Return the streak's length, and do it in O(n) time.

Related guides