All challenges
Algorithm challenge · DSA
Longest Consecutive Sequence
Difficulty
hard
Time
~35m
Format
Single
Grading
Auto-graded
#python#javascript#typescript#go#java#cpp#rust#dsa#hashing#arrays
Mission file // read carefullyhard
Given an unsorted array nums, return the length of the longest run of consecutive integers (e.g. 1,2,3,4). Aim for O(n).
Example
nums = [100,4,200,1,3,2] => 4 ([1,2,3,4])
Build with
longestConsecutive(nums: int[]) → intPythonJavaScriptTypeScriptGoJavaC++Rust
4 tests · 1 hidden
Auto-graded on submit
Start challenge
Sign in to save your progress.