How can we take in-place transpose fora 2d array?
Array rotation by 90deg
Hi @shivansh.sm1
There are two steps to rotate an array :
- Find transpose of matrix.
- 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]);
}