Js Array Partition problem

let arrs=[102,233,45,350,130,220,195,240]

I want arrs to split into two groups, but I want the sum of the two groups to be as close as possible. The smaller the difference, the better. My own idea is to re-sort, from small to large, and then judge the subscript to divide into two groups, odd group, even group, or the first two minimum values and the last two maximum values as a group, and the middle four as a group.
do you have a more accurate way to get the minimum difference?

Mar.22,2021

divide all the elements in the array by two
use this value to solve a < del > knapsack problem < / del > subset and problem (Subset sum problem)


"stupid" method

  

there is no solution to this problem, so please answer your needs again.

Menu