Rotate Matrix
Question (LC.48)
Analysis
Transpose
private int[][] transpose(int[][] matrix) {
int m = matrix.length;
int n = matrix[0].length;
int[][] result = new int[n][m];
for (int y = 0; y < m; y++) {
for (int x = 0; x < n; x++) {
result[x][y] = matrix[y][x];
}
}
return result;
}Vertical/Horizontal Flip
Rotate Matrix
Note
Last updated