Created
August 30, 2015 16:17
-
-
Save cxtadment/b97b57061c68a4921c7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]| | |
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. | |
Note: | |
You can assume each number in the array is a positive integer and not greater than 100. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment