Skip to content

Commit 197c32e

Browse files
authored
Update transpose-matrix.py
1 parent 25a6185 commit 197c32e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Python/transpose-matrix.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,14 @@ def transpose(self, A):
3636
for c, val in enumerate(row):
3737
result[c][r] = val
3838
return result
39+
40+
41+
# Time: O(r * c)
42+
# Space: O(1)
43+
class Solution2(object):
44+
def transpose(self, A):
45+
"""
46+
:type A: List[List[int]]
47+
:rtype: List[List[int]]
48+
"""
49+
return zip(*A)

0 commit comments

Comments
 (0)