Media.Net | Onsite | No. of ways an array can be split into two equal sum sequences

You are given an integer array of size N and you have to split it into two subsequences, both must have atleast one element and equal sum. There can be some elements in the array which are left undistributed. Now, count the number of ways in which the integers can be split.

Example:
Input -> [1,2,3,4,5,11]
Output -> 8
Explanation ->
The splits are as follows:

  • [1,2], [3] (same as [3], [1,2])
  • [1,3], [4]
  • [1,4], [5]
  • [2,3], [5]
  • [3,4], [5,2]
  • [2,4,5], [11]
  • [3,4,5], [1,11]
  • [1,2,3,5], [11]

Note:

  1. I think the interviewer has missed some cases and the output should be more than 8 (E.g. the split [2,4], [1,5] should also be valid). (At that time the question was clear to me so I didn't verify the output that he provided)

Constraints:
a. [N <= 100]
b. [-1000 <= total sum <= 1000]

Comments (3)