blob: 7b9e8b59353840135728e26465a8f035ecfdf664 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package kr.syeyoung.dungeonsguide.utils;
public class ArrayUtils {
public static int[][] rotateCounterClockwise(int[][] arr) {
int[][] res = new int[arr[0].length][arr.length];
for(int y=0; y<arr.length; y++) {
for (int x = 0; x< arr[0].length; x++) {
res[res.length - x - 1][y] = arr[y][x];
}
}
return res;
}
public static int[][] rotateClockwise(int[][] arr) {
int[][] res = new int[arr[0].length][arr.length];
for(int y=0; y<arr.length; y++) {
for (int x = 0; x< arr[0].length; x++) {
res[x][res[0].length - y - 1] = arr[y][x];
}
}
return res;
}
}
|