Given an array of integers, determine if it is possible to split

the array into two parts such that the sum of all elements in each part is the same.

Examples:

the array into two parts such that the sum of all elements in each part is the same.

Examples:

`splitArray({1,2,3,4}) ==> true`

`splitArray({1,2,4}) ==> false`

Need a **hand?** Try out these hints, one at a time.

1. Calculate the **sum of all the elements** in the input array. If it's an odd number, clearly the array cannot be split into two halves having the same sum.

2. If the sum is even, try to find a subset of the array which has an amount equal to**half of the total sum**.

2. If the sum is even, try to find a subset of the array which has an amount equal to

The target here would be half of the sum of all the elements in the input array. The idea is to recursively select each element and see if it can be used to reach the target.

1. If

`start_index >= length of the array`

, return `true`

if the target is zero, `false`

otherwise.2. Include the first first number and check the remaining elements i.e.

`groupSum(start_index+1, arr,`

`target - arr[start_index]))`

3. Exclude the first number and check the same the remaining elements i.e.

`groupSum(start_index+1, arr, target)`

public static boolean splitArray(int[] arr) { }

**C**

**Java**

**Python**