arrow_back Back to Challenges

#128 Longest Consecutive Sequence

Medium Acceptance 0%
description

Problem Description

Given an unsorted array of integers `nums`, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in `O(n)` time.

checklist Constraints

0 <= nums.length <= 10^5
-10^9 <= nums[i] <= 10^9

science Examples

Case #1

In: nums = [100,4,200,1,3,2]
Out: 4

Case #2

In: nums = [0,3,7,2,5,8,4,6,0,1]
Out: 9

Mastery Tags

Arrays Hash Table

Hiring Companies

Amazon Google Meta
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude