C++ Solution With Explanation
Priority Queue Implementation\n Make  a priority queue(binary max heap) which automatically arrange the element in sorted order.\n Then pick the first element (
**Priority Queue Implementation**\n* Make  a priority queue(binary max heap) which automatically arrange the element in sorted order.\n* Then pick the first element (which is maximum) and 2nd element(2nd max) , if both are equal  we dont have to push anything , if not equal push difference of both in queue.\n* Do the above steps till queue size is equal to 1, then return last element. If queue becomes empty before reaching size==1 then return 0.\n```\nclass Solution {\npublic:\n    int lastStoneWeight(vector<int>& stones) {\n        priority_queue<int> pq;\n        for(int i=0;i<stones.size();i++)\n        {\n            pq.push(stones[i]);\n        }\n        int m1,m2;\n        while(!pq.empty())\n        {\n            if(pq.size()==1)\n                return pq.top();\n            m1=pq.top();\n            pq.pop();\n            m2=pq.top();\n            pq.pop();\n            \n            if(m1!=m2)\n                pq.push(m1-m2);\n        }\n            return 0;\n        \n    }\n};\n```
['C', 'Heap (Priority Queue)', 'C++']