Ad
  • Custom User Avatar

    Could you explain me please a bit further why the correct answer is [3, 7] and not [5,5]? It is because the indexes for the second match are closer?

    sum_pairs([10, 5, 2, 3, 7, 5], 10)

    ^-----------^ 5 + 5 = 10, indices: 1, 5

    ^--^ 3 + 7 = 10, indices: 3, 4 *

    * entire pair is earlier, and therefore is the correct answer

    == [3, 7]

  • Custom User Avatar

    Oh, got it, thank you I usually think in terms of for's and if's

  • Custom User Avatar

    Is there a mathematical property to use?