Leetcode Problem 2679. Sum in a Matrix

2679. Sum in a Matrix

Leetcode Solutions

Sort Rows and Sum Column Maximums

  1. Iterate over each row in the 2D array nums.
  2. Sort each row in ascending order.
  3. Initialize a variable score to 0 to keep track of the sum of maximums.
  4. Iterate over the columns of the sorted 2D array.
  5. For each column, find the maximum value across all rows.
  6. Add the maximum value to score.
  7. Return the value of score.
UML Thumbnail

Use Priority Queue to Find Max in Columns

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...