Problem · Greedy
Maximize Machine Strength Sum
Learn this problemProblem statement
You are given n machines, each with at least two power units. The power units are represented by machinePowers, where machinePowers[i] contains the power values for the i-th machine.
The strength of a machine is the minimum power among all power units currently in that machine.
You may perform the following operation any number of times:
- Select an unmarked machine.
- Transfer exactly one power unit from that machine to any other machine.
- Mark the selected machine. A marked machine cannot be selected again, but it may still receive power units.
Return the maximum possible sum of strengths of all machines after performing operations optimally.
Function
maximizeMachineStrengthSum(machinePowers: int[][]) → longExamples
Example 1
machinePowers = [[2,7,4],[2,4,3]]return = 6Move the power unit 2 from the first machine to the second. The strengths become 4 and 2.
Constraints
1 <= machinePowers.length2 <= machinePowers[i].length- The total number of power units is at most
2 * 10^5.
More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026