public void rotate(int[][] matrix) {
        reverse(matrix);
        // swap the symmetry
        for (int i = 0; i < matrix.length; ++i) {
            for (int j = i + 1; j < matrix[0].length; ++j) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }

    }