Array rotation by 90deg

How can we take in-place transpose fora 2d array?

Hi @shivansh.sm1
There are two steps to rotate an array :

  1. Find transpose of matrix.
  2. Reverse columns of the transpose.

How can we find inplace transpose?

Hi @shivansh.sm1
To find transpose use the following code :

void transpose(int arr[R][C])
{
for (int i = 0; i < R; i++)
for (int j = i; j < C; j++)
swap(arr[i][j], arr[j][i]);
}

Hi @shivansh.sm1
Is your doubt resolved ?