aboutsummaryrefslogtreecommitdiff
path: root/other/set_matrix_0.rs
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
committerJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
commita96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch)
treee2a2b3f49f9fb741be81415266ac93e74cff42ec /other/set_matrix_0.rs
parent694ad5ed71edcb1deccab54b72d706b779918276 (diff)
downloadleetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz
leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/set_matrix_0.rs')
-rw-r--r--other/set_matrix_0.rs44
1 files changed, 0 insertions, 44 deletions
diff --git a/other/set_matrix_0.rs b/other/set_matrix_0.rs
deleted file mode 100644
index 78c434a..0000000
--- a/other/set_matrix_0.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-// 73. Set Matrix Zeroes
-// given an 'm x n' integer matrix 'matrix', if an element is 0,
-// set its entire row and column to 0's. must be done in place
-// (https://en.wikipedia.org/wiki/In-place_algorithm)
-
-impl Solution {
- pub fn set_zeroes(matrix: &mut Vec<Vec<i32>>) {
- let n_rows = matrix.len();
- let n_cols = matrix[0].len();
- let mut first_row = false;
- let mut first_col = false;
- for row in 0..n_rows {
- for col in 0..n_cols {
- if matrix[row][col] == 0 {
- if row == 0 {
- first_row = true;
- }
- if col == 0 {
- first_col = true;
- }
- matrix[0][col] = 0;
- matrix[row][0] = 0;
- }
- }
- }
- for row in 1..n_rows {
- for col in 1..n_cols {
- if matrix[row][0] == 0 || matrix[0][col] == 0 {
- matrix[row][col] = 0
- }
- }
- }
- if first_row {
- for col in 0..n_cols {
- matrix[0][col] = 0;
- }
- }
- if first_col {
- for row in 0..n_rows {
- matrix[row][0] = 0;
- }
- }
- }
-}