Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- Flutter
- 플러터
- 코틀린
- DART
- 알고리즘
- kotlin
- 프로그래머스
- java
- Android
- baekjoon
- aws
- Python
- 아마존 웹 서비스
- softeer
- 소프티어
- 코테
- programers
- 머신러닝
- MVVM
- GDSC
- SWIFT
- 개발
- 다트
- 현대sw
- 파이썬
- 자바
- 안드로이드
- 백준
- VSCode
- 스위프트
Archives
- Today
- Total
조준장 개발자 생존기
[baekjoon] 백준 10845번(파이썬): 큐 본문
문제
10845번: 큐
첫째 줄에 주어지는 명령의 수 N (1 ≤ N ≤ 10,000)이 주어진다. 둘째 줄부터 N개의 줄에는 명령이 하나씩 주어진다. 주어지는 정수는 1보다 크거나 같고, 100,000보다 작거나 같다. 문제에 나와있지
www.acmicpc.net
코드
import sys
from collections import deque
n = int(sys.stdin.readline())
queue = deque()
for i in range(n):
order = list(map(str, sys.stdin.readline().split()))
if order[0] == "pop":
if queue:
print(queue.popleft())
else:
print(-1)
elif order[0] == "size":
print(len(queue))
elif order[0] == "empty":
if queue:
print(0)
else:
print(1)
elif order[0] == "front":
if queue:
print(queue[0])
else:
print(-1)
elif order[0] == "back":
if queue:
print(queue[-1])
else:
print(-1)
elif order[0] == "push":
queue.append(order[1])
github
GitHub - junjange/CodingTest: 내가 푼 코딩 테스트 문제와 해결법
내가 푼 코딩 테스트 문제와 해결법. Contribute to junjange/CodingTest development by creating an account on GitHub.
github.com
'CodingTest > Baekjoon' 카테고리의 다른 글
[baekjoon] 백준 10866번(파이썬): 덱 (0) | 2021.09.06 |
---|---|
[baekjoon] 백준 1158번(파이썬): 요세푸스 문제 (0) | 2021.09.06 |
[baekjoon] 백준 1406번(파이썬): 에디터 (0) | 2021.09.06 |
[baekjoon] 백준 1874번(파이썬): 스택 수열 (0) | 2021.09.05 |
[baekjoon] 백준 9012번(파이썬): 괄호 (0) | 2021.09.04 |