Problem 3177 · Hard

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.

Open the interactive visualisation