Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.

Input: mat = [[1,2,3],[4,5,6],[7,8,9]]
Output: [1,2,4,7,5,3,6,8,9]
Input: mat = [[1,2],[3,4]]
Output: [1,2,3,4]
class Solution:
def findDiagonalOrder(self, mat: List[List[int]]) -> List[int]:
r = 0
c = 0
m = len(mat)
n = len(mat[0])
flag = True
result = [0] * (m*n)
for i in range(0, m*n):
result[i] = mat[r][c]
if (r + c) % 2 == 0: # moving up
if c == n - 1:
r+=1
elif r == 0 :
c+=1
else:
r-=1
c+=1
else: # moving down
if r == m - 1:
c+=1
elif c == 0:
r+=1
else:
r+=1
c-=1
return result
