terminal
Elevo
/
ESC
Login
Initiate Registration
code
Topics
corporate_fare
Companies
history
History
arrow_back
Back to Challenges
#128
Longest Consecutive Sequence
Medium
Acceptance 0%
Editorial
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
Python 3
expand_more
C
C++ 17
Java
JavaScript
Python 3
C
C++ 17
Java
JavaScript
Python 3
refresh
class Solution: def longestConsecutive(self, nums: list[int]) -> int: pass
Login to Compile
Processing
terminal
Debug Output
home
Home
extension
Practice
robot_2
login
Sign In
account_circle
Menu
code_blocks
Coding
psychology
Aptitude
Navigation
close
Login
Registration