← 返回 meta 的题目列表Minimum Operations to Sort Array
类型:online_judge
Given an integer array, compute the minimum number of operations needed to increase elements by 1 each time so the array becomes strictly increasing or strictly decreasing.
Input:
An integer array arr
Output:
An integer representing the minimum number of operations required
Example:
Input: [2, 3, 3, 2]
Output: 1
Explanation: Increase the second 3 by 1 to make the array strictly increasing [2, 3, 4, 2].
Data Scale:
The length of array arr is at most 1000.
Example
Input
[2, 3, 3, 2]