Image rotation problem doubt

can a generic code be written to transpose a matrix in o(1) space of an n*n matrix

Hi @RishabhSingh, the answer is yes.

sir provide code for it

Hi @RishabhSingh, see you just need to observe what is happening. Pls do not ask for code so quick. Do one thing. Take a pen and paper and write down a 4*4 matrix, its elements. Then write down another matrix which contains i,j at every like this:

(0,0) (0,1) (0,2) …
(1,0) (1,1) …

Now write the matrix 90* rotated anti-clockwise.
And after that the (i,j) matrix for the above rotated matrix. Like this:

(0,3) (1,3) (2,3) …
(1,0) (1,1) …

Now observe the pattern. Hope this helps :slight_smile:

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.