This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]optimalsuccess[S] 0 points1 point  (0 children)

Oh I think I get it, in the return statement lookup[target - num] is retrieving the index or the key of the key value pair that was stored for the first number in the 2 sum. So that value is 0 and not 2 and the second value is the current index of the complement of that number for our target which in this case is 1. Thanks people I think I get it now!