Files
PS/leetcode/118.py
Gyubin Han dede0dca01 leetcode
2025-02-19 14:09:55 +09:00

12 lines
307 B
Python

class Solution:
def generate(self, numRows: int) -> List[List[int]]:
arr=[[1]]
for r in range(2,numRows+1):
nr=[1]
for i in range(1,r-1):
nr.append(arr[r-2][i-1]+arr[r-2][i])
nr.append(1)
arr.append(nr)
return arr