-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path119.py
More file actions
26 lines (24 loc) · 669 Bytes
/
119.py
File metadata and controls
26 lines (24 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Solution:
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
if rowIndex < 0 or rowIndex is None:
return []
ans = list()
for n in range(rowIndex+1):
tmp = list([0])*(n+1)
if n == 0:
ans.append([1])
continue
tmp[-1], tmp[0] = 1, 1
for i in range(n+1):
if i == 0 or i == n:
continue
tmp[i] = ans[n-1][i-1] + ans[n-1][i]
ans.append(tmp)
return ans[rowIndex]
rowIndex = 0
test = Solution()
print(test.getRow(rowIndex))