Question DSA-ARR-0044
MediumWhat is the output of this code?
a = [16, 17, 4, 3, 5, 2]
res, mx = [], float("-inf")
for x in reversed(a):
if x > mx:
res.append(x)
mx = x
print(res[::-1])
- A.
[2, 5, 17]
- B.
[16, 17, 5, 2]
- C.
Sign up free to see the answer and a step-by-step explanation.