- We start by choosing a outer layer and rotating it. for this purpose we have a for loop which will select layer by layer.
- When a layer is selected next task is to rotate the selected layer, which is done using the second loop.

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

int temp;

int n=A.size();

for(int i=0;i<n/2;i++){

int x=n-1;

for(int j=i;j<n-1-i;j++){

temp=A[i][j];

A[i][j]=A[x-j][i];

A[x-j][i]=A[x-i][x-j];

A[x-i][x-j]=A[j][x-i];

A[j][x-i]=temp;

}

}

} - Comment if you have any doubt.

# O(n^2) Time & O(1) Space C++ easy to understand

**dikshant-rajwal**