Longest Consecutive Sequence(math)
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
Your algorithm should run in O(n) complexity.
Example:
分析
if i-1 in set 这样保证只从连续数里最小的开始。
while i+1 in set有连续就一直加 然后max一下
Last updated