Skip to content

Instantly share code, notes, and snippets.

@quake0day
Created March 26, 2016 03:59
Show Gist options
  • Save quake0day/48655a324e828c99bfd9 to your computer and use it in GitHub Desktop.
Save quake0day/48655a324e828c99bfd9 to your computer and use it in GitHub Desktop.
class Solution(object):
def generate(self, numRows):
"""
:type numRows: int;; rtype: List[List[int]]
"""
if not numRows: return []
ret = [[1]]
numRows -= 1
while numRows:
ret.append([1] + [a+b for a,b in zip(ret[-1][:-1], ret[-1][1:])] +[1])
numRows-=1
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment