heights (they are measured from some reference level and may be negative). In one step you can raise or lower any post by 1.
You want some width consecutive posts to end up at the same height. Return the minimum number of steps needed to achieve that.heights=[5, 1, 4, 2, 9], width=3 → 3
Take the window [1, 4, 2] and level it to 2: 1 step for the first column and 2 for the second, 3 in total. Every other window costs more.
heights=[-3, 7, 7, 0], width=2 → 0
The two neighbouring 7s are already the same height.
heights=[0, 10, -10], width=3 → 20
heights=[5, 1, 4, 2, 9], width=3
3
Run checks the first 3 tests in your browser. Submit checks all 253 tests on the server, hidden ones included.