Skip to content

Practice Sum in a Matrix

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2679
LeetCode Problem

Sum in a Matrix

Problem Statement

Start with score 0. In each round, remove one largest entry from every row of nums, then add the largest among those removed values to the score. Continue until all rows are empty. Return the final score.

Source: Sum in a Matrix on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [[7,2,1],[6,4,2],[6,5,3],[3,2,1]]
Output
15

# Example 2

Input
nums = [[1]]
Output
1

Constraints

1 <= nums.length <= 300
1 <= nums[i].length <= 500
0 <= nums[i][j] <= 10^3

Related LeetCode Problems

Practice more problems similar to Sum in a Matrix.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.