package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/rotate-image/
 */
public class Problem48 {
    public void rotate(int[][] matrix) {
        
    }
    
    public static void main(String[] args) {
		Problem48 prob = new Problem48();
		int n = 3;
		int[][] matrix = new int[n][n];
		int val = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				matrix[i][j] = val++;
			}
		}
		prob.rotate(matrix);
		for (int i = 0; i < n; i++) {
			System.out.println(Arrays.toString(matrix[i]));
		}
	}
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -141,128 +141,48 @@
     
-    %0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A%09%09Problem48 prob = new Problem48();%0A%09%09int n = 3;%0A%09%09
+%09int n = matrix.length;%0A        
 int%5B%5D%5B%5D 
 matr
@@ -177,22 +177,19 @@
 int%5B%5D%5B%5D 
-matrix
+tmp
  = new i
@@ -202,25 +202,16 @@
 n%5D;%0A
-%09%09int val = 0;%0A%09%09
+        
 for 
@@ -236,18 +236,24 @@
  i++) %7B%0A
-%09%09
+        
 %09for (in
@@ -279,67 +279,111 @@
 ) %7B%0A
-%09%09%09%09matrix%5Bi%5D%5Bj%5D = val++;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09prob.rotate(matrix);%0A%09
+        %09%09tmp%5Bi%5D%5Bj%5D = matrix%5Bi%5D%5Bj%5D;%0A        %09%7D%0A        %7D%0A        for (int i = 0; i %3C n; i++) %7B%0A        
 %09for
@@ -392,85 +392,94 @@
 int 
-i
+j
  = 0; 
-i
+j
  %3C n; 
-i
+j
 ++) %7B%0A
-%09%09%09System.out.println(Arrays.toString(matrix%5Bi%5D));%0A%09%09%7D%0A%09
+        %09%09matrix%5Bj%5D%5Bi%5D = tmp%5Bn-1-i%5D%5Bj%5D;%0A        %09%7D%0A        %7D%0A    
 %7D%0A%7D%0A

Solve problem 48