1359. Count All Valid Pickup and Delivery Options Hard

@problem@discussion
#Math#Dynamic Programming#Combinatorics



1/**
2 * [1359] Count All Valid Pickup and Delivery Options
3 *
4 * Given n orders, each order consist in pickup and delivery services. 
5 * Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). 
6 * Since the answer may be too large, return it modulo 10^9 + 7.
7 *  
8 * Example 1:
9 * 
10 * Input: n = 1
11 * Output: 1
12 * Explanation: Unique order (P1, D1), Delivery 1 always is after of Pickup 1.
13 * 
14 * Example 2:
15 * 
16 * Input: n = 2
17 * Output: 6
18 * Explanation: All possible orders: 
19 * (P1,P2,D1,D2), (P1,P2,D2,D1), (P1,D1,P2,D2), (P2,P1,D1,D2), (P2,P1,D2,D1) and (P2,D2,P1,D1).
20 * This is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2.
21 * 
22 * Example 3:
23 * 
24 * Input: n = 3
25 * Output: 90
26 * 
27 *  
28 * Constraints:
29 * 
30 * 	1 <= n <= 500
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/
36// discuss: https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn count_orders(n: i32) -> i32 {
42        0
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_1359() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.