GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/867_Transpose_Matrix.py at master · qiyuangong/leetcode Expand file tree/ Copy path867_Transpose_Matrix.pyMore file actions 23 lines (22 loc) · 646 Bytes / Copy path867_Transpose_Matrix.pyFile metadata and controls23 lines (22 loc) · 646 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution(object): def transpose(self, A): """ :type A: List[List[int]] :rtype: List[List[int]] """ R, C = len(A), len(A[0]) ans = [[None] * R for _ in xrange(C)] for r, row in enumerate(A): for c, val in enumerate(row): ans[c][r] = val return ans # Alternative Solution: # return zip(*A) # def transpose(self, A): # res = [] # for i in range(len(A[0])): # temp = [] # for j in range(len(A)): # temp.append(A[j][i]) # res.append(temp) # return res |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |