Count All Valid Pickup and Delivery Options LeetCode solution in Python

1
class Solution:
2
def countOrders(self, n: int) -> int:
3
total = 1
4
mod = 10**9 + 7
5
for k in reversed(range(2, n + 1)):
6
total = total * ((2 * k - 1) * (2 * k - 2) // 2 + 2 * k - 1)
7
total = total % mod
8
return total

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0