Split Array into Two Subsequences with Equal Average

Problem Given an array of numbers, split it into two non-empty subsequences whose averages are equal. Return the two subsequences, or report that no such split exists.

Input / Output

  • Input: array nums of n integers.
  • Output: the two subsequences (or a boolean feasibility answer); every element belongs to exactly one side.

Constraints

  • Every element must be used exactly once; both sides must be non-empty.
  • n typically <= 30, which is what makes subset-sum DP or meet-in-the-middle viable.
  • Not every array admits a split — [1,3] has no valid answer.

Example

  • [1,2,3,4,5,6] -> total sum 21, count 6, overall average 3.5. {1,6} averages 3.5 and the complement {2,3,4,5} also averages 3.5 -> valid split.
  • Tricky case: [1,3] -> averages could only be 1 and 3, never equal -> no split exists.
asked …
LeaderboardSalaryAccount