My Python solution


  • 0
    S
        def generate(self, numRows):
          if numRows == 0:
              return []
          pascal = [[1]]
          for i in range(1, numRows):
            pascal.append([1])
            for j in range(1,i):
              pascal[i].append(pascal[i-1][j] + pascal[i-1][j-1])
            pascal[i].append(1)
          return pascal

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.