Advertisement
arvind_iyer_2001

Untitled

Jun 19th, 2022
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. class Solution:
  2.     def findDiagonalOrder(self, nums: List[List[int]]) -> List[int]:
  3.         arr = []
  4.         l = len(nums)
  5.         d = {}
  6.         for i in range(l):
  7.             for j in range(len(nums[i])):
  8.                 if(i+j not in list(d.keys())):
  9.                     d[i+j] = []
  10.                 d[i+j].append(nums[i][j])
  11.        
  12.         for key in list(d.keys()):
  13.             diag = d[key]
  14.             l = len(diag)
  15.             for i in range(l)[::-1]:
  16.                 arr.append(diag[i])
  17.         return arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement