Skip to content

Commit f6e8544

Browse files
authored
Merge pull request #251 from qiaw99/patch-1
Create Solution.py
2 parents ff4e69c + 3c6ea49 commit f6e8544

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def generate(self, numRows: int) -> List[List[int]]:
3+
res = [[1], [1, 1]]
4+
if numRows == 0:
5+
return []
6+
elif numRows == 1:
7+
return [res[0]]
8+
9+
# from the 3. row on
10+
for i in range(2, numRows):
11+
counter = 1
12+
temp = [1, 1]
13+
# should add len(res[i - 1]) - 1 elements in to temp
14+
for j in range(len(res[i - 1]) - 1):
15+
temp.insert(counter, res[i - 1][j] + res[i - 1][j + 1])
16+
counter += 1
17+
res.append(temp)
18+
return res

0 commit comments

Comments
 (0)