Make Array Bitonic

Asked at Amazon · Coding Questions · Difficulty: Medium

In one operation you reduce any element by 1. A *bitonic* array may have zeros in a prefix and suffix; its non-zero part rises by 1 from 1 up to some peak `k`, then falls by 1 back to 1 (e.g. `[0,1,2,3,2,1,0,0]`). Return the minimum number of operations to make `arr` bitonic.

Loading the problem…