Dsa
Arrays
Medium
Largest Consecutive Sequence
Given an unsorted integer array, find the length of the longest consecutive elements sequence. The input consists of a single line with space-separated integers. The output should be a single integer representing the length of the longest consecutive sequence.
Example:
Input: 100 4 200 1 3 2
Output: 4
Explanation: The longest consecutive sequence is [1, 2, 3, 4], which has a length of 4.
Key concepts
arrayssetconsecutive-sequence
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now