SD_1_2's blog

By SD_1_2, history, 3 years ago, In English

Given an array , take 2 elements of a[i] and a[j] and take difference of a[i]-a[j] or a[j]-a[i] for i!=j and delete both elements and place the difference back into array and keep taking difference until we have one element in array with maximum possible value.

Arrays can contain negative and positive values.

input form : space separated integers of an array ouput : max value of differences until one element

INPUT 1: -5 3 -4 -2 -2 OP : 16

INPUT 2: 3 -3 2 -6 2 -1 OP:17

INPUT 3: 1 OP:1

INPUT4: -2 -4 -6 -8 OP: ?

INPUT 5: 2 4 6 8 10 OP:6

  • Vote: I like it
  • -46
  • Vote: I do not like it