@@ -0,0 +1,1026 @@
+/***%0A * You are given an n x n 2D matrix representing an image.%0A *%0A * Rotate the image by 90 degrees (clockwise).%0A *%0A * Follow up:%0A * Could you do this in-place?%0A */%0Apublic class Solution %7B%0A    // Two methods:%0A    // 1. Swap vals in symmetry along middle horizontal line, then Swap vals in symmetry along secondary diagonal line;%0A    // 2. Swap vals in symmetry along diagonal line, the swap vals in symmetry along middle horizontal line.%0A    // Either is OK.%0A    public void rotate(int%5B%5D%5B%5D matrix) %7B%0A        int n = matrix.length;%0A        if (n %3C= 1) return;%0A        int temp;%0A        for (int i = 0; i %3C n/2; i++)%0A            for (int j = 0; j %3C n; j++) %7B%0A                temp = matrix%5Bi%5D%5Bj%5D;%0A                matrix%5Bi%5D%5Bj%5D = matrix%5Bn - i - 1%5D%5Bj%5D;%0A                matrix%5Bn - i - 1%5D%5Bj%5D = temp;%0A            %7D%0A        for (int i = 0; i %3C n; i++)%0A            for (int j = 0; j %3C n; j++) %7B%0A                temp = matrix%5Bi%5D%5Bj%5D;%0A                matrix%5Bi%5D%5Bj%5D = matrix%5Bj%5D%5Bi%5D;%0A                matrix%5Bj%5D%5Bi%5D = temp;%0A            %7D%0A    %7D%0A%7D%0A

add RotateImage.java