Google | Phone | L4
Anonymous User
5352

Given a starting array of all zeroes and a target array of same length, return the minimum number of rangeIncrement operations needed to arrive at the target array.
For e.g. starting array = [0, 0, 0, 0, 0, 0] and target array = [4, 3, 1, 9, 2, 0]

A rangeIncrement(i, j) increments all elements in the array with index between i and j by 1.
For e.g. rangeIncrement(0, 4) on starting array [0, 0, 0, 0, 0, 0] would result in an array [1, 1, 1, 1, 1, 0]

The numbers present in target array are all guaranteed to be unique.

Comments (16)