Skip to content

Commit

Permalink
Create 04-sum-in-a-matrix.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 4, 2023
1 parent 4fceebf commit 3a154f6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 2023/07/04-sum-in-a-matrix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
impl Solution {
pub fn matrix_sum(mut nums: Vec<Vec<i32>>) -> i32 {
nums.iter_mut().for_each(|row| row.sort());
(0..nums[0].len())
.map(|i| nums.iter().map(|row| row[i]).max().unwrap())
.sum()
}
}

0 comments on commit 3a154f6

Please sign in to comment.