Link: https://leetcode.com/problems/longest-consecutive-sequence/
Solution:
Topics: hash map
Intuition
Cute little problem! Had fun solving this one. The code almost writes itself. There is one key edge case though: in the second path iterate over the elements in the set to avoid duplicates…we don’t want to be rechecking the same starting point…this alone can cause the algorithm to run in o(n*n)
!
Implementation