반응형
def solution(operations):
q = []
for command in operations:
if command[0] == "I":
q.append(int(command[2:len(command)]))
elif command == "D -1":
if len(q) > 0:
q.remove(min(q))
else:
if len(q) > 0:
q.remove(max(q))
if len(q) > 0:
answer = [max(q), min(q)]
else:
answer = [0, 0]
return answer
반례가 있을줄 알았는데 다행히 통과했다
화이팅!!
반응형
'개발💻 > 알고리즘' 카테고리의 다른 글
[프로그래머스] 등굣길 Python (1) | 2024.05.24 |
---|---|
[프로그래머스] 정수 삼각형 Python (0) | 2024.05.21 |
[프로그래머스] 단어변환 Python (20) | 2024.03.22 |
[프로그래머스] 베스트앨범 Python (21) | 2024.03.21 |
[프로그래머스] 네트워크 Python (21) | 2024.03.19 |