1359. Count All Valid Pickup and Delivery Options ¶ Time: Space: C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12class Solution { public: int countOrders(int n) { constexpr int kMod = 1'000'000'007; long ans = 1; for (int i = 1; i <= n; ++i) ans = ans * i * (i * 2 - 1) % kMod; return ans; } }; 1 2 3 4 5 6 7 8 9 10 11class Solution { public int countOrders(int n) { final int kMod = 1_000_000_007; long ans = 1; for (int i = 1; i <= n; ++i) ans = ans * i * (i * 2 - 1) % kMod; return (int) ans; } } 1 2 3 4 5 6 7 8 9class Solution: def countOrders(self, n: int) -> int: kMod = 1_000_000_007 ans = 1 for i in range(1, n + 1): ans = ans * i * (i * 2 - 1) % kMod return ans