Question DSA-SRCH-0063
HardWhat is the output of this code?
def find_peak(a):
lo, hi = 0, len(a) - 1
while lo < hi:
m = (lo + hi) // 2
if a[m] < a[m + 1]: lo = m + 1
else: hi = m
return lo
print(find_peak([1, 3, 20, 4, 1, 0]), find_peak([1, 2, 3, 4]))
- A.
2 3
- B.
2 0
- C.
Sign up free to see the answer and a step-by-step explanation.