Leetcode 1539 Solution
This article provides solution to leetcode question 1539 (diagonal-traverse-ii)
Access this page by simply typing in "lcs 1539" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/diagonal-traverse-ii
Solution
class Solution:
def findDiagonalOrder(self, nums: List[List[int]]) -> List[int]:
a = []
for i, num_arr in enumerate(nums):
for j, v in enumerate(num_arr):
a.append(((i, j), v))
a.sort(key=lambda ele: (ele[0][0] + ele[0][1], -ele[0][0], ele[0][1]))
return [v for _, v in a]