class Solution {
public int lastStoneWeight(int[] stones) {
PriorityQueue queue = new PriorityQueue(new Comparator() { @Override
public int compare(Integer o1, Integer o2) {
return - Integer.compare(o1,o2); } });
for (int i = 0; i = 2) {
int x = queue.poll();
int y = queue.poll();
if (x == y) continue;
if ( x <= y && x != y) queue.offer(y-x);
else if( y 0 ?queue.poll():0;
}}