Longest Consecutive Sequence — JavaScript medium interview problem
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. Example: `longestConsecutive([100,4,200,1,3,2])` → `4` (`1,2,3,4`).
Tags: set, union
Practice this HashMap & Set problem free in the JS Interview Playground with automated tests and unlockable solutions.