← 返回 ibm 的题目列表Maximum Increment to Make Array Ascending
类型:online_judge
Maximum Increment to Make Array Ascending
Given an integer array arr, determine the maximum increment that can be added to some elements to make the array strictly ascending.
Rules:
Adjacent elements cannot be modified.
All elements in the array are integers.
Input:
An integer array arr representing the original array.
Output:
An integer representing the maximum increment that can be added to make arr strictly ascending.
Example:
Input: arr = [1, 2, 6, 5, 3]
Output: 4
Explanation: Adding 4 to element at index 2 makes it arr[2] = 6 + 4 = 10, making the array [1, 2, 10, 5, 3] a strictly ascending sequence.
Constraints:
1 <= arr.length <= 10^5
-10^9 <= arr[i] <= 10^9
Example
Input
[1, 2, 6, 5, 3]