Question DSA-SRCH-0009
MediumWhat is the output of this code?
a = [4, 5, 6, 7, 0, 1, 2]
lo, hi = 0, len(a) - 1
while lo < hi:
mid = (lo + hi) // 2
if a[mid] > a[hi]:
lo = mid + 1
else:
hi = mid
print(a[lo])
- A.
3
- B.
2
- C.
Sign up free to see the answer and a step-by-step explanation.