没啥思路
class Solution:
def findDiagonalOrder(self, mat: List[List[int]]) -> List[int]:
m=len(mat)
n=len(mat[0])
ret=[]
if len(mat)==0:
return ret
count=0
#m+n-1是对角线总数
while count<m+n-1:
#x和y的和刚好是count数
#偶数为右上走
if count%2==0:
x=count if(count<m)else (m-1)
y=count-x
while(x>=0 and y<=n-1):
ret.append(mat[x][y])
x-=1
y+=1
#奇数左下走
else:
y=count if(count<n)else(n-1)
x=count-y
while(x<=m-1 and y>=0):
ret.append(mat[x][y])
x+=1
y-=1
count+=1
return ret