Question DSA-HASH-0008
MediumWhat is the output of this code?
nums, target = [2, 7, 11, 15], 9
seen = {}
ans = None
for i, x in enumerate(nums):
if target - x in seen:
ans = (seen[target - x], i)
break
seen[x] = i
print(ans)
- A.
(0, 2)
- B.
(1, 2)
- C.
Sign up free to see the answer and a step-by-step explanation.