Problem 3989 · Medium

Maximum Consistent Columns in a Grid

Keep a subsequence of grid columns so that, in every row, neighbouring kept columns stay within a fixed limit. A chain DP over column pairs finds the longest such subsequence.

Open the interactive visualisation