Minimum Suffix Operations to Reach a Target

Asked at Amazon · Coding Questions · Difficulty: Medium

In one operation you pick a segment ending at the last element (a suffix) and add `+1` or `-1` to every number in it. Return the minimum operations to make every element equal to `k`.

Loading the problem…