```
class Solution(object):
def findDiagonalOrder(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: List[int]
"""
if matrix == []:
return []
level = 0
queue = [(0,0)]
child = []
M = len(matrix)
N = len(matrix[0])
ans = []
while queue:
for i in queue:
r = i[0]
c = i[1]
if r+1 < M and (r+1,c) not in child:
child.append((r+1,c))
if c+1 < N and (r,c+1) not in child:
child.append((r,c+1))
level += 1
t = map(lambda x:matrix[x[0]][x[1]],queue)
if level % 2 == 0:
ans += t[::-1]
else:
ans += t
queue = child[:]
child = []
return ans
```