Solution
You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input.
Example
For inputArray = [1, 1, 1]
, the output should bearrayChange(inputArray) = 3
.
Input/Output
[input] array.integer inputArray
Guaranteed constraints:
3 ≤ inputArray.length ≤ 105
,-105 ≤ inputArray[i] ≤ 105
.[output] integer
The minimal number of moves needed to obtain a strictly increasing sequence from
inputArray
.
It's guaranteed that for the given test cases the answer always fits signed32
-bit integer type.
Solution
*count : sequence하게 올라가야 하는 횟수를 저장한 변수
'Programming > Algorithm' 카테고리의 다른 글
[Algorithm] areEquallyStrong (0) | 2018.03.02 |
---|---|
[Algorithm] palindromeRearranging (0) | 2018.02.26 |
[Algorithm] areSimilar (0) | 2018.02.26 |
[Algorithm] addBoarder (0) | 2018.02.26 |
[Algorithm] alternatingSums (0) | 2018.02.26 |