As reported: Amazon online assessments in June–Aug 2025, question 1 of 2 (an SDE-1 OA in Aug 2025 among them).
In an Amazon maintenance center there are n machines, each with m (m ≥ 2) power units; power[i][j] is the power of unit j of machine i. The strength of a machine is the minimum power among its units. Maximise the sum of strengths of all machines.
You may repeat this operation any number of times (possibly zero): select a machine that is not marked, transfer any one of its units to any other machine, and mark the selected machine. A marked machine can no longer give units, but it can still receive them — from several machines.
Example 1
power = [[1,5],[4,3],[2,10]]
Output: 16
Machine 1 gives its unit of power 1 to machine 2 → [[5],[1,4,3],[2,10]]; machine 3 gives its unit of power 2 to machine 2 → [[5],[1,2,4,3],[10]]. Strengths 5 + 1 + 10 = 16.
Example 2
power = [[2,7,4],[2,4,3]]
Output: 6 move a 2 from machine 1 to machine 2: min(7,4) + min(2,4,3,2) = 4 + 2
Constraints: 1 ≤ n; 2 ≤ m; n · m ≤ 2·10⁵; 1 ≤ power[i][j] ≤ 10⁹.
Code runner format: one line: power as a JSON array of n arrays of length m. Implement getStrength(power); the harness prints the result (it can exceed 32 bits).