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