mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
Time: 35 ms (56.96%), Space: 13.9 MB (12.45%) - LeetHub
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
class Solution:
|
||||||
|
def getRow(self, rowIndex: int) -> List[int]:
|
||||||
|
def combination(n: int, r: int) -> int:
|
||||||
|
# n! / (n - r)!
|
||||||
|
numerator = 1
|
||||||
|
for i in range(n - r + 1, n + 1):
|
||||||
|
numerator *= i
|
||||||
|
|
||||||
|
# 1 / r!
|
||||||
|
divisor = 1
|
||||||
|
for j in range(2, r + 1):
|
||||||
|
divisor *= j
|
||||||
|
|
||||||
|
return int(numerator / divisor)
|
||||||
|
|
||||||
|
return [ combination(rowIndex, i) for i in range(rowIndex + 1) ]
|
||||||
Reference in New Issue
Block a user