Skip to content

Instantly share code, notes, and snippets.

@JamesJi9277
Created April 1, 2015 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesJi9277/02244a6b64ba80ea9e5b to your computer and use it in GitHub Desktop.
Save JamesJi9277/02244a6b64ba80ea9e5b to your computer and use it in GitHub Desktop.
1.6
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