Question DSA-QUE-0044
MediumWhat is the output of this code?
from collections import deque
def josephus(n, k):
q = deque(range(1, n + 1))
while len(q) > 1:
q.rotate(-(k - 1))
q.popleft()
return q[0]
print(josephus(7, 3))
- A.
7
- B.
1
- C.
Sign up free to see the answer and a step-by-step explanation.