백준 - 2164

Giho Kim·2023년 9월 15일

코테 연습

목록 보기
5/26

문제

  1. 일단 1,2,3,4,5,6 리스트 만들어줌
  2. while len(q) != 1:
  3. popleft()한번 후 두번째 popleft()를 저장 후 append
from collections import deque


n = int(input())
stack = []
for i in range(1, n + 1):
  stack.append(i)
q = deque(stack)
while len(q) != 1:
  q.popleft()
  q.append(q.popleft())

print(q)
profile
취준돌이 개발자 김기호

0개의 댓글