Count All Valid Pickup and Delivery Options LeetCode solution in C++

1
class Solution {
2
public:
3
int countOrders(int n) {
4
int mod = 1e9 + 7;
5
long long ans = 1;
6
for (int i = 1; i <= n; i++) {
7
int m = 2 * i - 1;
8
int p = (m * (m + 1)) / 2;
9
ans = (ans * p) % mod;
10
}
11
return ans;
12
}
13
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0