class Solution {
public int lastStoneWeight(int[] stones) {
PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
int m1;
int m2;
for(int stone: stones){
pq.offer(stone);
}
while(pq.size() > 1){
m1 = pq.poll();
m2 = pq.poll();
if(m1 > m2) pq.offer(m1-m2);
}
return (pq.isEmpty()) ? 0: pq.peek();
}
}
