Ctrl K
Problem

Longest Unbroken Run

Medium · Longest Unbroken Run

You get an unordered integer array `values`. Find the largest `k` such that, for some `x`, all of `x, x + 1, …, x + k - 1` appear in the array (anywhere in it). Return `k`. Repeated values count once. For an empty array the answer is `0`. Sorting gives O(n log n); aim for O(n).…

Solve the problem →