Ctrl K

Peel Off the Row Maximums

Easy
You are given a table table of positive integers in which every row has the same length. A game is played in rounds until the table is empty: - every row loses its largest number (if there are several, any one of them); - the score grows by the largest of the numbers removed in that round. Each round makes every row one element shorter. Return the final score.
Example 1
table=[[2, 7, 5], [6, 1, 6]] → 15

Round 1 removes 7 and 6 and scores 7. Round 2 removes 5 and 6 and scores 6. Round 3 removes 2 and 1 and scores 2. Total: 7 + 6 + 2 = 15.

Example 2
table=[[4], [9], [1]] → 9

There is only one round, and the largest removed number in it is 9.

Example 3
table=[[3, 3]] → 6
Constraints
  • 1 ≤ len(table) ≤ 50
  • 1 ≤ len(table[i]) ≤ 50, all rows of equal length
  • 1 ≤ table[i][j] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsRounds of Row Maximums MediumThe Dimmest Rows EasyClearing the Stacks Evenly EasyMasha and Pete Stack the Cards EasyK-th Smallest in a Sorted Grid Medium
loading Python…
Input
table=[[2, 7, 5], [6, 1, 6]]
Expected
15

Run checks the first 3 tests in your browser. Submit checks all 90 tests on the server, hidden ones included.