linear time solution to longestConsecutive