Loading the catalog…
Loading the catalog…
https://www.hackerrank.com/contests/leetcode-bootcamp-week-1/challenges/set-matrix-zeroes-21/problem?isFullScreen=true 문제 2차원 배열 주어지면 해당 요소의 행과 열의 모든 요소 0 으로 (in-place) 답안 public static void setZeroes(List<List<Integer>> grid) { int row = grid.size(); int column = grid.get(0).size(); int[] rowCheck = new int[row]; int[] columnCheck = new int[column]; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { if (grid.get(i).get(j) == 0) { rowCheck[i] = 1; columnCheck[j] = 1; } } } for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { if (rowCheck[i] == 1 || columnCheck[j] == 1) { grid.get(i).remove(j); grid.get(i).add(j, 0); } } } } 메모 in-place 니까 돌면서 바꾸면 안 되고.. 체크해놓고 그 다음에 돌면서 바꿔줘야 된다. 단계적 사고~~
What RADAR observed and classified to build this opportunity. It is what the source published, not a verification that the offer is still active.
[LC BC] Set Matrix Zeroes 21. https://www.hackerrank.com/contests/leetcode-bootcamp-week-1/challenges/set-matrix-zeroes-21/problem?isFullScreen=true 문제 2차원 배열 주어지면 해당 요소의 행과 열의 모든 요소 0 으로 (in-place) 답안 public static void setZeroes(List > grid) { int row = grid.size(); int column = grid.get(0).size(); int[] rowCheck = new int[row]; int[] columnCheck = new int[column]; for (int i = 0; i < row; i++)…
Open sourceOpens an external website. Availability and terms may change.