Created
March 26, 2016 03:59
-
-
Save quake0day/48655a324e828c99bfd9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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