package main;

class MatrixTransformation {
    static int[][] rotateTo90Degrees(int[][] matrix) {
        return new int[][]{};
    }
}

@@ -104,28 +104,1003 @@
     
-return new int%5B%5D%5B%5D%7B%7D
+int n = matrix.length;%0A        if (n == 0 %7C%7C n != matrix%5B0%5D.length) return matrix;%0A        for (int layer = 0; layer %3C n/2; layer++) %7B%0A            rotateLayer(layer, matrix);%0A        %7D%0A        return matrix;%0A    %7D%0A%0A    private static void rotateLayer(int firstLayer, int%5B%5D%5B%5D matrix) %7B%0A        int n = matrix.length;%0A        int lastLayer = n - 1 - firstLayer;%0A        for (int i = firstLayer; i %3C lastLayer; i++) %7B%0A            rotateElement(firstLayer, i, lastLayer, matrix);%0A        %7D%0A    %7D%0A%0A    private static void rotateElement(int firstLayer, int currentLayer, int lastLayer, int%5B%5D%5B%5D matrix) %7B%0A        int offset = currentLayer - firstLayer;%0A        int tmp = matrix%5BfirstLayer%5D%5BcurrentLayer%5D;%0A        matrix%5BfirstLayer%5D%5BcurrentLayer%5D = matrix%5BlastLayer - offset%5D%5BfirstLayer%5D;%0A        matrix%5BlastLayer - offset%5D%5BfirstLayer%5D = matrix%5BlastLayer%5D%5BlastLayer - offset%5D;%0A        matrix%5BlastLayer%5D%5BlastLayer - offset%5D = matrix%5BcurrentLayer%5D%5BlastLayer%5D;%0A        matrix%5BcurrentLayer%5D%5BlastLayer%5D = tmp
 ;%0A  

Add solution for matrix rotation task. It takes O(n^2) time (cause implement element by element rotation) and constant space.