Question DSA-SRCH-0043
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(lo, a[lo])
- A.
6 2
- B.
0 4
- C.
Sign up free to see the answer and a step-by-step explanation.