0% completed
Why do you have to use a visited boolean array in this case instead of setting t...
Sana Madhavan
Aug 21, 2022
Why do you have to use a visited boolean array in this case instead of setting the visited notes to zero?
0
0
Comments
Design Gurus3 years ago
We don't have to use the visited array. We can update the input array to mark nodes.
Almost all of the questions under the Island Pattern can be solved without using the visited array.
However, sometime, the interviewer might not like if you change the input array. Mo...
Alfonso Vieyra3 years ago
I really liked the bitwise operation you used there! I would watch out though for people who may not understand exactly what that means.
Arpitha Anand3 years ago
private static boolean closedIsland(int[][] matrix, int r, int c) { //this condition will return false if there are any 1s in the edges of the matrix //which will result in isClosed = false if(r < 0 || r >= matrix.length || c < 0 || c >= matrix[0].length) { return false...
On this page