Implement the transpose of a matrix, where each element at position (i, j) is swapped to (j, i).
Transpose Operation:
(AT)ji=AijAn n×m matrix becomes an m×n matrix.
Input: A = [[1, 2, 3], [4, 5, 6]]
Output: [[1, 4], [2, 5], [3, 6]]
Input: A = [[1, 2], [3, 4]]
Output: [[1, 3], [2, 4]]
Input: A = [[1, 2, 3, 4]]
Output: [[1], [2], [3], [4]]
Create an output array whose row and column counts are reversed.
Inside nested loops, assign output[j, i] from A[i][j].
Sign in to take notes on this problem
Accepts: array
Implement the transpose of a matrix, where each element at position (i, j) is swapped to (j, i).
Transpose Operation:
(AT)ji=AijAn n×m matrix becomes an m×n matrix.
Input: A = [[1, 2, 3], [4, 5, 6]]
Output: [[1, 4], [2, 5], [3, 6]]
Input: A = [[1, 2], [3, 4]]
Output: [[1, 3], [2, 4]]
Input: A = [[1, 2, 3, 4]]
Output: [[1], [2], [3], [4]]
Create an output array whose row and column counts are reversed.
Inside nested loops, assign output[j, i] from A[i][j].
Sign in to take notes on this problem
Accepts: array