Phase 1: Add all numbers to a hash set.
Phase 2: For each number in the set:
- If is not in the set, is a sequence start
- Count consecutive numbers: until not found
- Update the maximum length
Why is this ?
Each number is the start of exactly one sequence. The inner counting loop visits each number at most once across all iterations. Time: . Space: .