Leetcode 898 Solution
This article provides solution to leetcode question 898 (transpose-matrix)
Access this page by simply typing in "lcs 898" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/transpose-matrix
Solution
class Solution:
def transpose(self, A: List[List[int]]) -> List[List[int]]:
m = len(A)
n = len(A[0])
ans = [[0] * m for _ in range(n)]
for i, j in itertools.product(range(m), range(n)):
ans[j][i] = A[i][j]
return ans