867. Transpose Matrix
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 15, 2024
Last updated : June 15, 2024
Related Topics : Array, Matrix, Simulation
Acceptance Rate : 73.12 %
class Solution:
def transpose(self, matrix: List[List[int]]) -> List[List[int]]:
output = [[0] * len(matrix) for _ in range(len(matrix[0]))]
for row in range(0, len(matrix)) :
for col in range(0, len(matrix[0])) :
output[col][row] = matrix[row][col]
return output