1424. Diagonal Traverse II
https://leetcode.com/problems/diagonal-traverse-ii
Python
from collections import defaultdict
class Solution:
def findDiagonalOrder(self, nums: List[List[int]]) -> List[int]:
mapper = defaultdict(list)
for i in range(len(nums)-1, -1, -1):
for j in range(len(nums[i])):
mapper[i+j].append(nums[i][j])
result = []
for key in sorted(mapper.keys()):
result += mapper[key]
return result