1359. Count All Valid Pickup and Delivery Options
Contents
https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/
https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/submissions/1045563113/
class Solution {
public:
int countOrders(int n) {
vector<int> dp(n + 1);
dp[1] = 1;
for(int i = 2; i <= n; ++i){
int tn = (2 * i - 1);
int sn = (tn * (tn + 1)) / 2;
dp[i] = (long long)dp[i - 1] * sn % 1000000007;
}
return dp[n];
}
};
Looked Hint