Skip to content
Advertisement

Boolean recursive static method that gets an array of integers

I’m trying to write a method that would Return true if it is possible to divide all the members of an array into two different groups of equal size so that the sum of the members of the two groups is equal. If this is not possible, the method Return false.

The conditions are:

  • The method should be recursive with no use of loops at all, So are all the auxiliary methods Can not contain loops.
  • The array is neither null nor empty.
  • Do not modify the contents of the array (not even temporarily), and do not use an auxiliary array.
JavaScript
JavaScript

I got stuck here and i have no clue what to do next.

Advertisement

Answer

something like this should solve your problem and handle all cases.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement