 0

# Split Array With the Same Average

Difficulty: HARD Contributed By
Shrey Pansuria
Avg. time to solve
15 min
Success Rate
85%

Problem Statement

#### A group of ninjas want to play a game of tag but they can only do that if each team has the same average strength of abilities among the two divided teams. You are given a list (array named ‘strengths’) of the strengths of the group of ninjas represented by numbers (integers). You have to determine whether those ninjas can be regrouped into two different teams such that the average strength of the two teams formed is equal.

##### Note:
``````You have to move each ninja of given strength from the given list into two separate teams (list) ‘Team_A’ and ‘Team_B’ such that the average strengths of ‘Team_A’ == ‘Team_B’. There has to be at least one member in each team since they cannot play the game without that.
``````
##### For Example:
``````Input : [1, 7, 15, 29, 11, 9]
Output : [9, 15] [1, 7, 11, 29]

Explanation: The average strengths of both the teams is 12
``````
##### Input Format:
``````The first line of input contains a single integer ‘N’ denoting the number of ninjas, whose list of strengths which would be given in the list.

The second line contains ‘N’ single space-separated integers, denoting the strengths of the ninjas.
``````
##### Output Format :
``````Print "True" if the ninjas can be regrouped into two different teams having same average strengths and "False" is they cannot be regrouped.
``````
##### Note:
``````You do not need to print anything, it has already been taken care of. Just implement the given function.
``````
##### Constraints:
``````1 <= N <= 30
0 <= strengths[i] <= 10^4

Time Limit: 1 sec
``````
##### Sample Input 1 :
``````8
1 2 3 4 5 6 7 8
``````
##### Sample Output 1:
``````True
``````

#### Explanation Of Sample Input 1:

``````We can split the array into [1, 4, 5, 8] and [2, 3, 6, 7], and both of them have an average of 4.5.
``````
##### Sample Input 2 :
``````2
3 1
``````
##### Sample Output 2 :
``````False
``````

#### Explanation Of Sample Input 2:

``````We cannot split the array into two parts as all the combinations would not have same average in both parts.
``````   Console