Problem 4066 · Medium

Maximum Equal Adjacent Pairs After at Most One Replacement

Merging two values makes exactly their adjacent pairs equal. Count neighbour pairs of distinct values and add the largest tally to the existing equal pairs.

Open the interactive visualisation