알고리즘/프로그래머스
[Python] 이중 우선순위 큐
dding96
2022. 12. 9. 09:25
https://school.programmers.co.kr/learn/courses/30/lessons/42628
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
def solution(operations):
answer = []
for i in operations:
oper = i.split()
if oper[0] == 'I':
answer.append(int(oper[1]))
elif oper[0] == 'D':
if answer == []:
continue
else:
if oper[1] == '1':
answer.remove(max(answer))
elif oper[1] == '-1':
answer.remove(min(answer))
if answer == []:
return [0,0]
else:
return [max(answer), min(answer)]
정답은 맞혔는데 다른 사람들의 풀이를 보면 이렇게 푸는 게 아닌 것 같다.....
자료구조와 알고리즘을 더 공부해야 할 듯