The Question
CodingLongest Consecutive Sequence
Given an unsorted array of integers, design an algorithm to find the length of the longest sequence of consecutive elements (e.g., [1, 2, 3, 4]). The solution must achieve O(n) time complexity, where n is the number of elements in the array.
Java
HashSet
Greedy
March 20, 2026