Rotation as 4 groups


#1

void Solution::rotate(vector<vector > &matrix) {

    int len = matrix.size();
    for (int i = 0; i < len / 2; i++) 
    {
        for (int j = i; j < len - i - 1; j++) 
        {
        int tmp = matrix[i][j];
        matrix[i][j] = matrix[len - j - 1][i];
        matrix[len - j - 1][i] = matrix[len - i - 1][len - j - 1];
        matrix[len - i - 1][len - j - 1] = matrix[j][len - i - 1];
        matrix[j][len - i - 1] = tmp;
        }
    }
}