Rotate Image (n x n) anticlockwize

https://ide.codingblocks.com/s/52833

#2 test case show run time error
and pls also tell how can we do same que without taking any another array

mention problem link pls

@ankush9818744825
your code is correct just change the array size from a[10][10] to a[1001][1001] similarly b.

To solve this without using extra space:

  • take transpose of matrix then take image about x axis. ( verify this through example).

Hit like if you get it :smiley:
Cheers!
Happy Coding :smiley:

2 Likes

not get your words properly can yu pls!!! explain it brifely pls!!!

To solve this without using extra space:
steps to rotate a matrix of N*N
step 1: take transpose of matrix (swap a[i][j] and a[j][i] )
step 2: then take the image of matrix about x axis, by this, i mean that, if matrix is
eg; 1 2 3
4 5 6
7 8 9

then image about axis will be:
7 8 9
4 5 6
1 2 3

Apply these steps to the matrix you will get the desired matrix.
Hit like if you get it :smiley:
Cheers!
Happy Coding :smiley:

1 Like

how to take the image of matrix about x axis