How do I check if the sum of the numbers of 1st half and 2nd half of an array is same?

Given an array of even size. I have to determine if sum of any combination of the numbers (half of the size) is equal to sum for other half numbers of the array.

Example:

6=array size
The array is=1,2,3,4,5,6

Here I have to make combination of (6/2)=3 numbers which sum is equal to sum of rest of the numbers of the array. If not possible then answer - NO.

Another example:

4=array size
The array is=2,3,4,5
Here sum of combination of (4/2)=2 numbers is
3+4=7
2+5=7

So answer is-Yes

How do I do it using C++?

Topic archived. No new replies allowed.