Medium Problemsoptimizationlinear

Longest Subsequence with 1 adjacent difference

Given an array of integers, find the length of the longest subsequence in which every pair of consecutive chosen values differs by exactly 1.

Do this lesson first: house robber

The full breakdown and animated table for this problem are still being written. In the meantime, run the four questions on it yourself — that is the whole exercise.