To rotate it anti-clockwise, we have to reverse rows using a row pointer for the STL method. but for clockwise, we have to reverse columns. how to reverse the column using the reverse method.
Rotate Image Question
The anticlock wise rotation approach was:
- Take transpose along the diagonal.
This you can do by: if(i!=j) then swap(arr[i][j],arr[j][i]) - Reverse all rows.
This you can do by: swap(arr[i][j],arr[i][n-1-j])
If you want the rotation in anti clockwise direction, you will have to take transpose along the other diagonal.
Then reverse all rows.
Just do some index manipulation and swap the elements. Check for the indexes by considering any example and generalize a formula for swapping elements in order to from the transposed matrix.
So there is nothing like column pointer. only row pointer exist a[i];
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.