1461. Count All Valid Pickup and Delivery Options
My accepted Python solution to LeetCode problem 1461, Count All Valid Pickup and Delivery Options, running in 0ms.
- Difficulty: Hard
- Python
- Runtime 0ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.2MB, accepted 2026-01-02.
class Solution:
def countOrders(self, n: int) -> int:
MOD = 10**9 + 7
result = 1
for i in range(1, n + 1):
result = result * i * (2 * i - 1) % MOD
return result