Ad
  • Custom User Avatar

    If you're still stuck, post your code (put a line of three backticks ``` before and after) and mark it as "having spoiler content".
    As much as I appreciate reading an algorithm in English, it might be easier to see your problems in JavaScript.

  • Default User Avatar

    Id assume we are looking at the last index value, so 7's index of 4 is before the second 5's index of 5

  • Default User Avatar

    How does [5,5] ends earlier than [3,7] ?

  • Custom User Avatar

    Tiebreaking considers the entire pair, so you need to look at the end instead. [5,5] ends earlier than [3,7].

  • Default User Avatar

    Why is the below [3,7] instead of [5,5]?
    Doesn't [5,5] occur first if we start from the left?

    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]
    
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Oh my..how does one even think of that