LeetCode 128: Longest Consecutive Sequence — Step-by-Step Visual Trace
Medium — Array | Hash Table | Union Find
The Problem
Given an unsorted array of integers, find the length of the longest sequence of consecutive elements. The algorithm must run in O(n) time complexity.
Approach
Convert the array to a set for O(1) lo...
blog.tracelit.dev1 min read