public int LastStoneWeight(int[] stones) { MaxPQ maxPQ = new MaxPQ(stones); while (maxPQ.Count() >= 2) { int x = maxPQ.RemoveMax(); int y = maxPQ.RemoveMax(); if (x != y) { maxPQ.Insert(Math.Abs(x - y)); } } if (maxPQ.IsEmpty()) { return(0); } else { return(maxPQ.RemoveMax()); } }