Created
April 1, 2015 19:37
-
-
Save JamesJi9277/02244a6b64ba80ea9e5b to your computer and use it in GitHub Desktop.
1.6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution{ | |
public void rotateMatrix(int[][] matrix){ | |
if(matrix == null || matrix.length == 0|| matrix[0].length ==0) | |
return; | |
int row = matrix.length; | |
for(int i =0; i < row/2; i++) | |
{ | |
for(int j =0;j< n-1-i;j++) | |
{ | |
matrix temp = matrix[i][j]; | |
matrix[i][j] = matrix[row - j - 1][i]; | |
matrix[row - j - 1][i] = matrix[row - i -1][row-j-1]; | |
matrix[row-i-1][row-j-1] = matrix[j][row-i-1]; | |
matrix[j][row-i-1] = temp; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment