From c46aaea1b37f51c0a19bd02ecc31e79f97e91b00 Mon Sep 17 00:00:00 2001 From: Vikas-Bagri <86218885+Vikas-Bagri@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:02:05 +0530 Subject: [PATCH 1/6] Create code.txt --- 2dArray/BooleanMatrix/code.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 2dArray/BooleanMatrix/code.txt diff --git a/2dArray/BooleanMatrix/code.txt b/2dArray/BooleanMatrix/code.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/2dArray/BooleanMatrix/code.txt @@ -0,0 +1 @@ + From b609be1da698f71e4e7ecb2318a09d5081ab3035 Mon Sep 17 00:00:00 2001 From: Vikas-Bagri <86218885+Vikas-Bagri@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:02:42 +0530 Subject: [PATCH 2/6] Delete code.txt --- 2dArray/BooleanMatrix/code.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 2dArray/BooleanMatrix/code.txt diff --git a/2dArray/BooleanMatrix/code.txt b/2dArray/BooleanMatrix/code.txt deleted file mode 100644 index 8b13789..0000000 --- a/2dArray/BooleanMatrix/code.txt +++ /dev/null @@ -1 +0,0 @@ - From cfe61ad8b175f0b79ef1ca5312815050ed359675 Mon Sep 17 00:00:00 2001 From: Vikas-Bagri <86218885+Vikas-Bagri@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:03:49 +0530 Subject: [PATCH 3/6] Create demo.txt --- 2dArrays/BooleanMatrix/demo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 2dArrays/BooleanMatrix/demo.txt diff --git a/2dArrays/BooleanMatrix/demo.txt b/2dArrays/BooleanMatrix/demo.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/2dArrays/BooleanMatrix/demo.txt @@ -0,0 +1 @@ + From 4dd968297b2a7c976ea91ae1b75c63dfc8b44e46 Mon Sep 17 00:00:00 2001 From: Vikas-Bagri <86218885+Vikas-Bagri@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:04:58 +0530 Subject: [PATCH 4/6] Delete 2dArrays/BooleanMatrix directory --- 2dArrays/BooleanMatrix/demo.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 2dArrays/BooleanMatrix/demo.txt diff --git a/2dArrays/BooleanMatrix/demo.txt b/2dArrays/BooleanMatrix/demo.txt deleted file mode 100644 index 8b13789..0000000 --- a/2dArrays/BooleanMatrix/demo.txt +++ /dev/null @@ -1 +0,0 @@ - From d695c8f50f53aa5306137e08d5b798d5514e4277 Mon Sep 17 00:00:00 2001 From: Vikas-Bagri <86218885+Vikas-Bagri@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:05:36 +0530 Subject: [PATCH 5/6] Create demo.txt --- 2dArrays/BooleanMatrix/demo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 2dArrays/BooleanMatrix/demo.txt diff --git a/2dArrays/BooleanMatrix/demo.txt b/2dArrays/BooleanMatrix/demo.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/2dArrays/BooleanMatrix/demo.txt @@ -0,0 +1 @@ + From 0ad34c1bde21165342704a63481a361145bc5e5f Mon Sep 17 00:00:00 2001 From: Vikas-Bagri <86218885+Vikas-Bagri@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:09:52 +0530 Subject: [PATCH 6/6] Added solution of the problem 'Boolean Matrix'. --- 2dArrays/BooleanMatrix/Solution.java | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 2dArrays/BooleanMatrix/Solution.java diff --git a/2dArrays/BooleanMatrix/Solution.java b/2dArrays/BooleanMatrix/Solution.java new file mode 100644 index 0000000..0bd8b89 --- /dev/null +++ b/2dArrays/BooleanMatrix/Solution.java @@ -0,0 +1,29 @@ +class Solution +{ + //Function to modify the matrix such that if a matrix cell matrix[i][j] + //is 1 then all the cells in its ith row and jth column will become 1. + void booleanMatrix(int matrix[][]) + { + // code here + int r = matrix.length; + int c = matrix[0].length; + int rTemp[] = new int[r]; + int cTemp[] = new int[c]; + for(int i = 0; i < r; i++){ + for(int j = 0; j < c; j++){ + if(matrix[i][j] == 1){ + rTemp[i] = 1; + cTemp[j] = 1; + } + } + } + + for(int i = 0; i < r; i++){ + for(int j = 0; j < c; j++){ + if(rTemp[i] == 1 || cTemp[j] == 1){ + matrix[i][j] = 1; + } + } + } + } +} \ No newline at end of file