3566. Partition Array into Two Equal Product Subsets Medium

@problem@discussion
#Array#Bit Manipulation#Recursion#Enumeration



1/**
2 * [3566] Partition Array into Two Equal Product Subsets
3 *
4 * You are given an integer array nums containing distinct positive integers and an integer target.
5 * Determine if you can partition nums into two non-empty disjoint subsets, with each element belonging to exactly one subset, such that the product of the elements in each subset is equal to target.
6 * Return true if such a partition exists and false otherwise.
7 * A subset of an array is a selection of elements of the array.
8 *  
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">nums = [3,1,6,8,4], target = 24</span>
12 * Output: <span class="example-io">true</span>
13 * Explanation: The subsets [3, 8] and [1, 6, 4] each have a product of 24. Hence, the output is true.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">nums = [2,5,3,7], target = 15</span>
18 * Output: <span class="example-io">false</span>
19 * Explanation: There is no way to partition nums into two non-empty disjoint subsets such that both subsets have a product of 15. Hence, the output is false.
20 * </div>
21 *  
22 * Constraints:
23 * 
24 * 	3 <= nums.length <= 12
25 * 	1 <= target <= 10^15
26 * 	1 <= nums[i] <= 100
27 * 	All elements of nums are distinct.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/partition-array-into-two-equal-product-subsets/
33// discuss: https://leetcode.com/problems/partition-array-into-two-equal-product-subsets/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn check_equal_partitions(nums: Vec<i32>, target: i64) -> bool {
39        false
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_3566() {
51    }
52}
53

Back
© 2026 bowen.ge All Rights Reserved.