Loading the catalog…
Loading the catalog…
https://www.hackerrank.com/contests/leetcode-bootcamp-week-1/challenges/rotate-image-31-1/problem?isFullScreen=true 문제 2차원 배열 주어지면 시계 방향으로 90도 회전 답안 public static void rotate(List<List<Integer>> grid) { int row = grid.size(); int column = grid.get(0).size(); for (int i = 0; i < row; i++) { for (int j = i + 1; j < column; j++) { int tmp = grid.get(i).get(j); grid.get(i).remove(j); grid.get(i).add(j, grid.get(j).get(i)); grid.get(j).remove(i); grid.get(j).add(i, tmp); } } for (int i = 0; i < row; i++) { for (int j = column - 1; j >= 0; j--) { int tmp = grid.get(i).get(j); grid.get(i).remove(j); grid.get(i).add(tmp); } } } 메모 90도 돌리려면 행렬을 transpose 하고, 각 행을 역순으로 바꿔주면 된다. transpose 는 어떻게 하는가.. 가 어려웠는데 for 문에서 대각선 위쪽만 돌아주면 되는 것! 그리고는 쓸데없이 List<List > 로 인풋을 줘서 그거 처리하는 것만 어려웠다.
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] Rotate Image 31. https://www.hackerrank.com/contests/leetcode-bootcamp-week-1/challenges/rotate-image-31-1/problem?isFullScreen=true 문제 2차원 배열 주어지면 시계 방향으로 90도 회전 답안 public static void rotate(List > grid) { int row = grid.size(); int column = grid.get(0).size(); for (int i = 0; i = 0; j--) { int tmp = grid.get(i).get(j); grid.get(i).remove(j); grid.get(i).add(tmp); } } } 메모 90도 돌리려면 행렬을…
Open source