Skip to content

Instantly share code, notes, and snippets.

@agoodkind
Last active June 19, 2018 18:17
Show Gist options
  • Save agoodkind/16409405175bc670b242cf3352925d44 to your computer and use it in GitHub Desktop.
Save agoodkind/16409405175bc670b242cf3352925d44 to your computer and use it in GitHub Desktop.
class Solution:
# @param a : list of list of integers
# @return a list of list of integers
def diagonal(self, a):
m = len(A)
n = len(A[0])
res = [0]*(m+n-1)
res = self.build(res)
res = self.fill(A,res,m,n)
return res
def build(self,res):
for i in range(len(res)):
res[i] = []
return res
def fill(self, A, res, m, n):
for i in range(m):
for j in range(n):
res[i+j].append(A[i][j])
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment