S
All challenges
Practice
Home
Blog
Practice
Examples
Feedback
Longest Consecutive Sequence
00:00
Start
00:00
Sign in
Problem
Hints
3
Solution
History
Medium
Array
HashSet
Google
Facebook
Find length of longest sequence of consecutive integers in an unsorted array. Must be O(n).
Examples
Example 1
Input →
[100,4,200,1,3,2]
Output →
4
Note:
sequence 1,2,3,4
Example 2
Input →
[0,3,7,2,5,8,4,6,0,1]
Output →
9
Note:
0-8
Example 3
Input →
[1]
Output →
1
JavaScript
Python
Java (Coming soon)
C (Coming soon)
C++ (Coming soon)
Reset
Run
Submit
Cases
Results