class Solution():
def turn(self,A):
res = list(zip(*A))
res = res[::-1]
return res
def printmatrix(self,A):
ans = []
while(A):
ans+=(A.pop(0))
if not A or not A[0]:
break
A = self.turn(A)
return ans
#test
s = Solution()
A = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
print(s.printmatrix(A))
#test
网友评论