- from typing import List
- def generate(numRows: int) -> List[List[int]]:
- ret = list()
- for i in range(numRows):
- res = list()
- for j in range(0, i + 1):
- if j == 0 or j == i:
- res.append(1)
- else:
- res.append(ret[i - 1][j - 1] + ret[i - 1][j])
- ret.append(res)
- return ret
- print(generate(5))
|