← 返回 amazon 的题目列表Minimize Array Sum with Minimum Copy Operations
类型:online_judge
amazon
Given an integer array effort of length n, you can choose two positions i and j in each move, with i < j, and replace the value at position j with the value at position i (i.e., effort[j] = effort[i]). The goal is to minimize the sum of values in the entire array with the minimum number of operations. Return the minimum number of operations required.
Example 1:
Input: effort = [3, 6, 9, 12]
Output: 3
Example 2:
Input: effort = [5, 5, 5, 5]
Output: 0
Constraints:
1 <= n <= 1000
1 <= effort[i] <= 1000
Example
Input
3 6 9 12