@@ -1,25 +0,0 @@
-from typing import List
-
-def generate(numRows: int) -> List[List[int]]:
- i = 1
- res = []
- while i <= numRows:
- if i == 1:
- res.append([1])
- i += 1
- elif i == 2:
- res.append([1, 1])
- elif i > 2:
- a = -1
- res.append([1, i + a, 1])
- a = i + a
- return res
-print(generate(4))
@@ -0,0 +1,16 @@
+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))
@@ -0,0 +1,15 @@
+def getRow(rowIndex: int) -> List[int]:
+ for i in range(rowIndex + 1):
+ return res
+print(getRow(6))