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.
Hash Set Intelligent Lookup
To achieve O(n) time, we can store all numbers in a HashSet. For each number `x`, we check if it is the start of a sequence by verifying that `x - 1` is NOT in the set. If it is the start, we increment to `x + 1, x + 2...` and track the length. This ensures each element is visited only a few times.