一共有n个order,每个order先进行pickup操作,再进行delivery操作,问完成n个order一共几种序列
思路参考-> https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/solutions/516968/java-c-python-easy-and-concise/
1 #1359
2 #Runtime: 13 ms (Beats 77.42%)
3 #Memory: 13.2 MB (Beats 80.65%)
4
5 class Solution(object):
6 def countOrders(self, n):
7 """
8 :type n: int
9 :rtype: int
10 """
11 MOD = 10 ** 9 + 7
12 ans = 1
13 for i in range(2, n + 1):
14 ans = ans * (2 * i - 1) * i % MOD
15 return ans