You are viewing a single comment's thread. Return to all comments →
In JAVA8 :
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PriorityQueue<Integer> minHeap = new PriorityQueue<>(); int i = 0, Q = Integer.parseInt(br.readLine().trim()); while (i++ < Q) { String[] input = br.readLine().split(" "); switch(Integer.parseInt(input[0])){ case 1 :{ minHeap.offer(Integer.parseInt(input[1])); break; } case 2 :{ minHeap.remove(Integer.parseInt(input[1])); break; } case 3 :{ System.out.println(minHeap.peek()); break; } default :{ System.out.println("Invalid !"); } } } } }
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →
In JAVA8 :