Tap here to switch tabs
Problem
Submissions

Problem: Sum in a Matrix

med
30 min
Try to solve the Sum in a Matrix problem.

Statement

You are given a 00 indexed 22D integer array nums. You begin with a score of 00.

Repeat the following process until the matrix is empty:

  1. From each row, select and remove the element with the highest value. If there is a tie, any one of the highest elements may be removed.

  2. Determine the maximum value among all elements removed in this step.

  3. Add this maximum value to your score.

Return the final score after all elements are removed from nums.

Constraints:

  • 1≤1 \leq nums.length ≤300\leq 300

  • 1≤1 \leq nums[i].length ≤500\leq 500

  • 0≤0 \leq nums[i][j] ≤103\leq 10^3

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum in a Matrix

med
30 min
Try to solve the Sum in a Matrix problem.

Statement

You are given a 00 indexed 22D integer array nums. You begin with a score of 00.

Repeat the following process until the matrix is empty:

  1. From each row, select and remove the element with the highest value. If there is a tie, any one of the highest elements may be removed.

  2. Determine the maximum value among all elements removed in this step.

  3. Add this maximum value to your score.

Return the final score after all elements are removed from nums.

Constraints:

  • 1≤1 \leq nums.length ≤300\leq 300

  • 1≤1 \leq nums[i].length ≤500\leq 500

  • 0≤0 \leq nums[i][j] ≤103\leq 10^3