import collections
N = 6
queue = collections.deque([i for i in range(1, N+1)])
print(list(queue))
print("-"*5)
while queue :
tmp = queue.popleft()
last_num = queue.popleft()
queue.append(last_num)
# print(list(queue))
if len(queue) == 1:
print(queue[0])
break
'leetcode 풀이 > 큐, 스택 (Array)' 카테고리의 다른 글
boj-5397. 키 로거 (0) | 2023.01.20 |
---|---|
boj-7785. 회사에있는사람 (0) | 2023.01.20 |
boj-11866. 요세푸스 문제 (0) | 2023.01.19 |
leetcode 46. Permutations 순열 (0) | 2022.04.03 |
leetcode 153 - Find Minimum in Rotated Sorted Array (0) | 2022.03.28 |
댓글