#3566

Partition Array into Two Equal Product Subsets

medium · 35.1% accepted · 78 likes · top 13%

array · bit manipulation · recursion · enumeration

Description

You are given an integer array nums containing distinct positive integers and an integer target.

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.

Return true if such a partition exists and false otherwise.

A subset of an array is a selection of elements of the array.

Solution