classSolution:deffindDiagonalOrder(self,mat: List[List[int]]) -> List[int]:ifnot mat ornot mat[0]:return [] R =len(mat) C =len(mat[0]) res = [] tmp = []for i inrange(R + C -1): tmp.clear() r =0if i < C else i - C +1 c = i if i < C else C -1while r < R and c >-1: tmp.append(mat[r][c]) r +=1 c -=1if i %2==0: res.extend(tmp[::-1])else: res.extend(tmp)return res