From 436799173245d808a3d5e90870d7990ea6e6b49c Mon Sep 17 00:00:00 2001 From: Subash Mandal <117103537+SubashMandal070@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:54:57 +0530 Subject: [PATCH] Create SetMatrixZero.java Name : Subash Kumar Mandal --- SetMatrixZero.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SetMatrixZero.java diff --git a/SetMatrixZero.java b/SetMatrixZero.java new file mode 100644 index 0000000..561b597 --- /dev/null +++ b/SetMatrixZero.java @@ -0,0 +1,23 @@ +void setMatrixZeros(int A[][], int M, int N) +{ + int temp[M][N] + for (i = 0 to M-1) + for (j = 0 to N-1) + temp[i][j] = 1 + for(i = 0 to M - 1) + { + for (j = 0 to N - 1) + { + if (A[i][j] == 0) + { + for (k = 0 to M - 1) + temp[k][j] = 0 + for (k = 0 to N - 1) + temp[i][k] = 0 + } + } + } + for (i = 0 to M-1) + for (j = 0 to N-1) + arr[i][j] = temp[i][j] +}