equal average partition

Правка en1, от wish_me, 2017-10-07 20:36:19

Given an array with non negative numbers, divide the array into two parts such that the average of both the parts is equal. Return both parts (If exist).

If there is no solution. return an empty list.

Example:

Input:

[1 7 15 29 11 9]

Output:

[9 15] [1 7 11 29]

The average of part is (15+9)/2 = 12,

average of second part elements is (1 + 7 + 11 + 29) / 4 = 12

arr.size<10^3

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский wish_me 2017-10-07 20:36:19 430 Initial revision (published)