码迷,mamicode.com
首页 > 其他好文 > 详细

Minimum Adjustment Cost

时间:2016-06-29 18:34:21      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/sherylwang/p/5627769.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!