Coding Challenge

Longest Consecutive Sequence

Medium
arrayhashset

Find the longest run of consecutive integers.

Return the length of the longest sequence of consecutive integers present in the array in overall linear time.

Examples

Input: nums = [100,4,200,1,3,2]

Output: 4

Constraints

  • Values can be unsorted

Preparing your coding workspace...