File tree 3 files changed +46
-0
lines changed
solution/1300-1399/1359.Count All Valid Pickup and Delivery Options
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,23 @@ public:
113
113
};
114
114
```
115
115
116
+ ### **Rust**
117
+
118
+ ```rust
119
+ const MOD: i64 = 1e9 as i64 + 7;
120
+
121
+ impl Solution {
122
+ #[allow(dead_code)]
123
+ pub fn count_orders(n: i32) -> i32 {
124
+ let mut f = 1;
125
+ for i in 2..=n as i64 {
126
+ f = (i * (2 * i - 1) * f) % MOD;
127
+ }
128
+ f as i32
129
+ }
130
+ }
131
+ ```
132
+
116
133
### ** Go**
117
134
118
135
``` go
Original file line number Diff line number Diff line change @@ -90,6 +90,23 @@ public:
90
90
};
91
91
```
92
92
93
+ ### **Rust**
94
+
95
+ ```rust
96
+ const MOD: i64 = 1e9 as i64 + 7;
97
+
98
+ impl Solution {
99
+ #[allow(dead_code)]
100
+ pub fn count_orders(n: i32) -> i32 {
101
+ let mut f = 1;
102
+ for i in 2..=n as i64 {
103
+ f = (i * (2 * i - 1) * f) % MOD;
104
+ }
105
+ f as i32
106
+ }
107
+ }
108
+ ```
109
+
93
110
### ** Go**
94
111
95
112
``` go
Original file line number Diff line number Diff line change
1
+ const MOD : i64 = 1e9 as i64 + 7 ;
2
+
3
+ impl Solution {
4
+ #[ allow( dead_code) ]
5
+ pub fn count_orders ( n : i32 ) -> i32 {
6
+ let mut f = 1 ;
7
+ for i in 2 ..=n as i64 {
8
+ f = ( i * ( 2 * i - 1 ) * f) % MOD ;
9
+ }
10
+ f as i32
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments