Minimum Adjustment Cost

Posted Sheryl Wang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Minimum Adjustment Cost相关的知识,希望对你有一定的参考价值。

Given an integer array, adjust each integers so that the difference of every adjacent integers are not greater than a given number target.

If the array before adjustment is A, the array after adjustment is B, you should minimize the sum of |A[i]-B[i]|

 Notice

You can assume each number in the array is a positive integer and not greater than 100.

Example

Given [1,4,2,3] and target = 1, one of the solutions is [2,3,2,3], the adjustment cost is 2 and it‘s minimal. 

Return 2.

以上是关于Minimum Adjustment Cost的主要内容,如果未能解决你的问题,请参考以下文章