Easy C++ solution (In place easy solution)


#1
void Solution::rotate(vector<vector<int> > &A) 
{
    int n=A.size();
    // Take the transpose of the matrix
    for(int i=0;i<n;i++)
    {
        for(int j=i;j<n;j++)
        {
            swap(A[i][j],A[j][i]);
        }
    }
    // Reverse the columns
    for(int i=0;i<n;i++)
    {
        reverse(A[i].begin(),A[i].end());
    }
}