Solve the longest consecutive sequence problem in leetcode, O(n) for both time and space complexity.