Question DSA-TP-0041
MediumWhat is the output of this code?
a = [1, 2, 4, 7, 11, 15]
t = 15
i, j = 0, len(a) - 1
while i < j:
s = a[i] + a[j]
if s == t:
break
if s < t:
i += 1
else:
j -= 1
print(a[i], a[j])
- A.
4 11
- B.
2 15
- C.
1 15
- D.
7 11
Sign up free to see the answer and a step-by-step explanation.