2741. Special Permutations Medium
1/**
2 * [2741] Special Permutations
3 *
4 * You are given a 0-indexed integer array nums containing n distinct positive integers. A permutation of nums is called special if:
5 *
6 * For all indexes 0 <= i < n - 1, either nums[i] % nums[i+1] == 0 or nums[i+1] % nums[i] == 0.
7 *
8 * Return the total number of special permutations. As the answer could be large, return it modulo 10^9 + 7.
9 *
10 * <strong class="example">Example 1:
11 *
12 * Input: nums = [2,3,6]
13 * Output: 2
14 * Explanation: [3,6,2] and [2,6,3] are the two special permutations of nums.
15 *
16 * <strong class="example">Example 2:
17 *
18 * Input: nums = [1,4,3]
19 * Output: 2
20 * Explanation: [3,1,4] and [4,1,3] are the two special permutations of nums.
21 *
22 *
23 * Constraints:
24 *
25 * 2 <= nums.length <= 14
26 * 1 <= nums[i] <= 10^9
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/special-permutations/
32// discuss: https://leetcode.com/problems/special-permutations/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn special_perm(nums: Vec<i32>) -> i32 {
38 0
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_2741() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.