Back to problems

Longest Consecutive Sequence (variation)

Algorithm · Rippling · Medium

Problem: Longest Consecutive Integer Sequence You are given an integer array nums in arbitrary order. Determine the size of its longest run of integers that increase by exactly one at each step. Such a run has the pattern [x, x+1, x+2, ...]. Every number in the run must occur somewhere in nums, although those values are not required to sit next to one another in the input array. Input A single space-delimited line containing the integers of nums. Output Print one integer:…

Checking your access…