Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
There are at most <code>k + 1</code> possible values of the integer <code>X</code>.
How do we calculate the minimum number of changes efficiently if we fix the value of <code>X</code> before applying any changes?