Input: mat[][] = [[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[4, 4, 4, 4]]
Output: [[1, 2, 3 ,4],
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4]]
Explanation: The output is the transpose of the input matrix, where each row becomes a column. This rearranges the data so that vertical patterns in the original matrix become horizontal in the result.
Input: mat[][] = [[1, 2],
[9, -2]]
Output: [[1, 9],
[2, -2]]
Explanation: The output is the transpose of the input matrix, where each row becomes a column. This rearranges the data so that vertical patterns in the original matrix become horizontal in the result.