Ad
  • Custom User Avatar

    In your last example {1,2,3,4,5,6} the answer is -1 because you can not select one position and have both sides equal the same number. In your answer ({1,2,3} = {6} => 1) you have chosen to select 2 positions to work around rather than one: position 3 and 4. I have no idea where you got the number 1 for that answer, but the answer is -1 because you can not select one position where both sides are equal.

    As for your original question: ({2824, 1774, -1490, -9084, -9696, 23094} => 1 how is that happen?), let's take a look at the answer.

    You have {2824, 1774, -1490, -9084, -9696, 23094}.
    You have to select a position where both sides are equal.
    Let's start with position 0
    At position 0 the number is 2824, to the left of position 0 is {} (we count this as a 0), and to the right of it is {1774, -1490, -9084, -9696, 23094} (sum of these = 4598)
    We compare the sums: 0 != 4598 so this is not our answer.
    Next is position 1
    At position 1 we have 1774, to the left of position is {2824} (sum = 2824), and to the right of position 1 is {-1490, -9084, -9696, 23094} (sum = 2824)
    We compare the sums: 2824 == 2824 so this IS our answer!
    We return position 1 as our correct answer.


    If you have any other difficulties understanding this problem let me know and I'll see if I can set you straight.