very easy code  with explanation
step 1  create a priority queue\nstep 2 Put all elements into a priority queue.\nstep 3 take two bigest element \npush the difference into queue until\ntwo more
**step 1  create a priority queue\nstep 2 Put all elements into a priority queue.\nstep 3 take two bigest element \npush the difference into queue until\ntwo more element left.**\n\n**Complexity\nTime O(NlogN)\nSpace O(N)**\n\n\n\n\n```\nclass Solution {\npublic:\n    int lastStoneWeight(vector<int>& nums) {\n       priority_queue<int> pq;\n      for(auto i : nums)      \n          pq.push(i);\n      while(pq.size() > 1)\n      {\n          int a = pq.top();\n          pq.pop();\n          int b = pq.top(); \n          pq.pop();\n       if(a>b)\n              pq.push(a-b);\n      }\n      return pq.empty()?0:pq.top();  \n        \n    }\n};\n\nif(ishelpfull)\n(upvote);\n\n
[]