[
2d-array
]
Leetcode 0867 Transpose Matrix
Problem statement
https://leetcode.com/problems/transpose-matrix/
Solution
In python it can be done with one simple line with O(mn) complexity. Also we can return list() if needed in the end.
Complexity
Time and space is O(mn).
Code
class Solution:
def transpose(self, matrix):
return zip(*matrix)