'Find and store transpose of a non-square matrix into itself without using any extra array/matrix

We have to find the transpose of a non square matrix without using any other array except the one that we are inputting, i.e., we have to make changes in the same matrix.

I tried the one method used for square matrices but it does not seem to work for the non square matrices.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source