Skip to main content
Back to problems
Leetcode
Medium
Arrays
Backtracking
Combinatorics
Number Theory
Partition Array Into Two Equal Product Subsets

Determine whether an array can be split into two non-empty subsets whose element products are equal.

Acceptance 50%
Problem Statement

Problem

Given an array of integers, decide whether it is possible to split the elements into two non-empty groups such that the product of all numbers in the first group is exactly the same as the product of all numbers in the second group.

Every element must belong to exactly one of the two groups.

Return true if such a split exists, otherwise return false.

Notes

  • The two groups must both contain at least one element.
  • You may assume all values are integers.
  • A practical solution usually needs careful search, pruning, or a mathematical reformulation rather than checking every split naively.

Input Format

  • An integer array nums.
  • The array length and value range are not specified here; solve the general interview version.

Output Format

  • Return a boolean indicating whether the array can be partitioned into two non-empty subsets with equal product.

Constraints

  • Both subsets must be non-empty.
  • Each array element must be used exactly once.
  • The exact official constraints are unknown from the provided metadata.
Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [2, 3, 6]

Output

true

Explanation

One valid split is [2, 3] and [6]. Both subsets have product 6.

Example 2

Input

nums = [1, 2, 4]

Output

false

Explanation

The possible non-empty splits are [1] and [2, 4], [2] and [1, 4], or [4] and [1, 2]. Their products are 1 vs 8, 2 vs 4, and 4 vs 2, so no split has equal products.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.