Ad
  • Custom User Avatar

    I think by "different items" means different items of the array, not different values of those items. Hence values can be equal but items (indexes) must be different.

  • Custom User Avatar

    The problem statement is "The input will always be valid (numbers will be an array of length 2 or greater, and all of the items will be numbers; target will always be the sum of two different items from that array)."

    The input can be repeated numbers, i.e if target is 4 , input can be [2,2,1,3] . The above solution gives (0,1) , but actual ans is(2,3) as target will always be the sum of two different items from that array.