Find the Maximum Length of a Good Subsequence II
Keep, for each value and change count, the best chain ending there, so each new number only looks up the best values to join.
Keep, for each value and change count, the best chain ending there, so each new number only looks up the best values to join.