All Problems
mediumLists

Matrix Transpose

Problem Statement
Given a matrix of r rows and c columns, find its transpose.

SAMPLE INPUT

2 3
1 2 3
4 5 6

SAMPLE OUTPUT

1 4
2 5
3 6

CONSTRAINTS

  • 1 <= r, c <= 100

Explanation: Swap rows and columns: transpose[j][i] = matrix[i][j].

Code Editor
Output
Click "Run" to see output...