I have priority queue in Java of Integers:
PriorityQueue pq= new PriorityQueue();
When I call pq.poll(
pq.poll(
You can use MinMaxPriorityQueue (it's a part of the Guava library): here's the documentation. Instead of poll(), you need to call the pollLast() method.
MinMaxPriorityQueue
poll()
pollLast()