Question DSA-TP-0043
MediumWhat is the output of this code?
h = [1, 8, 6, 2, 5, 4, 8, 3, 7]
i, j, best = 0, len(h) - 1, 0
while i < j:
best = max(best, min(h[i], h[j]) * (j - i))
if h[i] < h[j]:
i += 1
else:
j -= 1
print(best)
- A.
56
- B.
64
- C.
Sign up free to see the answer and a step-by-step explanation.