(프로그래머) 이중 우선순위 큐 – Java

https://school.programmers.co.kr/learn/courses/30/lessons/42628

프로그램 제작자

코드 중심 개발자를 고용하십시오. 배치 기반 위치 매칭. 프로그래머의 개발자별 프로필에 가입하고 기술 호환성이 좋은 회사와 연결하십시오.

Programmer.co.kr

import java.util.*;

class Solution {
    public int() solution(String() operations) {
       int ans() = new int(2);
        PriorityQueue<Integer> maxQ = new PriorityQueue<>(Collections.reverseOrder());
        PriorityQueue<Integer> minQ = new PriorityQueue<>();
        ArrayList<Integer> list = new ArrayList<>();
        
        for(String s: operations){
            String() arr = s.split(" ");
            int num = Integer.parseInt(arr(1));
            if(arr(0).equals("I")) {
                maxQ.add(num);
                minQ.add(num);
                list.add(num);
            }else{
                if(num == -1) maxQ.remove(minQ.poll());
                else minQ.remove(maxQ.poll());
            }
        }
        ans(0) = maxQ.isEmpty() ? 0: maxQ.peek();
        ans(1) = minQ.isEmpty() ? 0: minQ.peek();
        return ans;
    }
}