Question DSA-QUE-0041
MediumWhat is the output of this code?
from collections import deque
q = deque([1, 2, 3, 4, 5])
k = 3
s = list(q)[:k][::-1]
q = deque(s + list(q)[k:])
q.rotate(-1)
print(list(q))
- A.
[1, 4, 5, 3, 2]
- B.
[2, 3, 4, 5, 1]
- C.
Sign up free to see the answer and a step-by-step explanation.