The problem, in one line. Given an unsorted list of numbers, return the length of the longest run of values that go up by one, in linear time. LeetCode 128.
The tell. You need neighbours by value, not by position, and the list is unsorted with a linear time demand. When “is the next value present?” must be instant, put everything in a set.
Included with a plan
This solution is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.