這個Leetcode難題是很好的中學數學問題,排列問題。
[codes on Leetcode] https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/solutions/4024293/c-python-math-recursion-1-loop/
class Solution:
    def countOrders(self, n: int) -> int:
        mod=10**9+7
        num=1
        for i in range(1, n):
            num=num*(i+1)*(2*i+1)%mod
        return num
有一行解的。
 
   
 
 
沒有留言:
張貼留言