Skip to content

Commit b7cadd1

Browse files
authored
feat: add rust solution to lc problem: No.1359 (#1596)
1 parent 83b9b3b commit b7cadd1

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ public:
113113
};
114114
```
115115
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+
116133
### **Go**
117134

118135
```go

solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README_EN.md

+17
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ public:
9090
};
9191
```
9292
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+
93110
### **Go**
94111

95112
```go
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}

0 commit comments

Comments
 (0)