make all values zero of an integer array with minimum no. of binary operations
make all values zero of an integer array with minimum no. of binary operations I am working on a research project, where I need to convert an integer array's all value to zero using minimum no. of binary(addition/ subtraction only) operations. For e.g. Input Array: [ -9 , -3, -2, 8, 5, 1 ] Output: 4 operations: op1) -9 + 8 = -1 op2) -1 + 1 = 0 op3) -3 + 5 = 2 op4) -2 + 2 = 0 Input array: [ -6, -5, -4, 6, 9] output: 3 operations: 1) -6+6 = 0 2) -5 + 9 = 4 3) -4 + 4 =0 I cannot think of even the brute force solution. constraints: Minimum number of Binary operations(addition/subtraction only). Why do you need to do this? – Tim Biegeleisen Jul 1 at 14:30 its a variation of Hungarian algorithm with additional constraints for the project work. – pankaj kashyap Jul 1 at 14:35 ...