Ad
  • Custom User Avatar

    This should be more clear in the description

  • Custom User Avatar

    Others have answered it, but this is a bit of a "gotcha" element to the question.

    With the "earliest pair" and "parse from the left please" statements, I'm trying to hint at the following behavior: Imagine the list doesn't exist until you begin parsing values one-by-one, inserting them as you go along. If your algorithm was capable of finding the first pair that exists as elements get added, that would be the perfect solution.

    Example with k-goldon's set:

    [1]                    # No pair exists to sum 6
    [1, 3]                 # No pair exists to sum 6 
    [1, 3, 0]              # No pair exists to sum 6
    [1, 3, 0, 4]           # No pair exists to sum 6
    [1, 3, 0, 4, 6]        # The 0 and 6 adds up to 6! We're DONE!
    
  • Default User Avatar

    Very questionable use of the phrase "entire pair is earlier". Entire pair is NOT earlier in your example. In the first pair, the first element is earlier, in the second - second is earlier. It seems that the description is matched to the algorithm.

  • Custom User Avatar

    Element with higher position decides of position of pair.
    For example:
    for sum = 6 in [1, 3, 0, 4, 6, 3, 8] there are two pairs: 3, 3 (at pos. 1, 5) and 0, 6 (at 2, 4). (3,3) is at 5 and (0, 6) is at 4. So "entire pair (0, 6) is earlier".