As reported: Amazon SDE-II interview (Amazon Music team, July 2025), round 1 — two Leadership Principle questions, then two coding questions; this was the first: balloons in a line, each with a number; shooting a balloon scores
shooting order × balloon value(a balloon worth 5 shot third scores 15); find the maximum total score after shooting all balloons.
values[i] is the number on balloon i. You shoot every balloon exactly once, in any order. The k-th shot (1-based) scores k × value of the balloon hit. Return the maximum total score.
Example 1
values = [3,1,5]
Output: 22 shoot 1, 3, 5: 1·1 + 2·3 + 3·5
Example 2
values = [5,2,4,1]
Output: 37 1·1 + 2·2 + 3·4 + 4·5
Constraints: 1 ≤ n ≤ 10^5; 1 ≤ values[i] ≤ 10^5. The answer can exceed 32 bits.
Code runner format: one line: values as a JSON array. Implement maxScore(values); the harness prints the result.