Build the PrimitiveMedium
Longest Consecutive Sequence
Write `longest_consecutive(nums)` returning the length of the longest run of consecutive integers present in the list. The values are unsorted and may repeat.
longest_consecutive([100, 4, 200, 1, 3, 2]) -> 4 (1, 2, 3, 4)
Sorting gives O(n log n) and is worth mentioning before you discard it. For O(n): put everything in a set, and only start counting upward from a value whose predecessor is absent. That guard is what makes the whole thing linear rather than quadratic — be ready to prove it, because it is the follow-up.
What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.