JAVA solution


  • 0
    5
      public static void rotate(int[][] matrix) {
    	int len=matrix.length;
    	int end=len-1;
    	for(int i=0;i<len/2;i++){
    		for(int j=i;j<end-i;j++){
    			int t=matrix[i][j];
    			matrix[i][j]=matrix[end-j][i];
    			matrix[end-j][i]=matrix[end-i][end-j];
    			matrix[end-i][end-j]=matrix[j][end-i];
    			matrix[j][end-i]=t;
    		}
    	}
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.