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
'Algorithm > 기본 알고리즘' 카테고리의 다른 글
| boj-5397. 키 로거 (0) | 2023.01.20 |
|---|---|
| boj-7785. 회사에있는사람 (0) | 2023.01.20 |
| boj-11866. 요세푸스 문제 (0) | 2023.01.19 |
| leetcode 21. Merge Two Sorted Lists (0) | 2022.08.28 |
| [기본 알고리즘] Binary Search (0) | 2022.08.28 |