서울의 아침에 하는 리트코드...
쉬운걸로 했다...
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
ans = [[1]]
for i in range(1, numRows):
row = [1]
for j in range(i-1):
row.append(ans[i-1][j] + ans[i-1][j+1])
row.append(1)
ans.append(row)
return ans
끝!
'Leetcode' 카테고리의 다른 글
Leetcode 20. Valid Parentheses (0) | 2021.11.15 |
---|---|
Leetcode 122. Best Time to Buy and Sell Stock II (0) | 2021.11.10 |
441. Arranging Coins (0) | 2021.11.05 |
129. Sum Root to Leaf Numbers (0) | 2021.11.03 |
232. Implement Queue using Stacks (0) | 2021.11.02 |