2164(카드2) - 자료구조(큐)

지환·2023년 10월 8일
0

백준(python)

목록 보기
55/67
post-thumbnail

출처 | https://www.acmicpc.net/problem/2164

코드

import sys
from collections import deque

n = int(sys.stdin.readline())
card = deque()

for i in range(1, n+1):
    card.append(i)
    
while len(card) > 1:
    card.popleft()
    card.append(card.popleft())

print(card[0])

  • deque만 알고 있다면 쉽게 풀 수 있는 문제다.
profile
아는만큼보인다.

0개의 댓글