diff --git a/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README.md b/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README.md index 239c00e1ef969..49e917b52dc40 100644 --- a/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README.md +++ b/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README.md @@ -113,6 +113,23 @@ public: }; ``` +### **Rust** + +```rust +const MOD: i64 = 1e9 as i64 + 7; + +impl Solution { + #[allow(dead_code)] + pub fn count_orders(n: i32) -> i32 { + let mut f = 1; + for i in 2..=n as i64 { + f = (i * (2 * i - 1) * f) % MOD; + } + f as i32 + } +} +``` + ### **Go** ```go diff --git a/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README_EN.md b/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README_EN.md index 2a2e26a0b1154..b5136d3631dbe 100644 --- a/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README_EN.md +++ b/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/README_EN.md @@ -90,6 +90,23 @@ public: }; ``` +### **Rust** + +```rust +const MOD: i64 = 1e9 as i64 + 7; + +impl Solution { + #[allow(dead_code)] + pub fn count_orders(n: i32) -> i32 { + let mut f = 1; + for i in 2..=n as i64 { + f = (i * (2 * i - 1) * f) % MOD; + } + f as i32 + } +} +``` + ### **Go** ```go diff --git a/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/Solution.rs b/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/Solution.rs new file mode 100644 index 0000000000000..ef4da2cb41764 --- /dev/null +++ b/solution/1300-1399/1359.Count All Valid Pickup and Delivery Options/Solution.rs @@ -0,0 +1,12 @@ +const MOD: i64 = 1e9 as i64 + 7; + +impl Solution { + #[allow(dead_code)] + pub fn count_orders(n: i32) -> i32 { + let mut f = 1; + for i in 2..=n as i64 { + f = (i * (2 * i - 1) * f) % MOD; + } + f as i32 + } +} \ No newline at end of file