You are given a 2D integer array matrix, return the transpose of matrix.
The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.
Example 1:
Input: matrix = [
[2,1],
[-1,3]
]
Output: [
[2,-1],
[1,3]
]Example 2:
Input: [
[1,0,5],
[2,4,3]
]
Output: [
[1,2],
[0,4],
[5,3]
]Constraints:
m == matrix.lengthn == matrix[i].length1 <= m, n <= 10001 <= m * n <= 100,000-1,000,000,000 <= matrix[i][j] <= 1,000,000,000