learn heap(max)
Intuition\n Describe your first thoughts on how to solve this problem. \nconcept maching with heap:\n\n# Approach\n Describe your approach to solving the proble
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nconcept maching with heap:\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nfirst, find max and second max\nif same then pop both else change larger elem as diff.\nat the end print ele. remaining on heap\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(NlogN)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int lastStoneWeight(vector<int>& stones) {\n        priority_queue<int>pq;\n        for(auto ele:stones){\n            pq.push(ele);\n        }\n        while(pq.size()>1){\n            int x=pq.top();\n            pq.pop();\n            int y=pq.top();\n            pq.pop();\n            if(x-y) pq.push(x-y);\n        }\n        return pq.size()==0?0:pq.top();\n\n        \n    }\n};\n```
['C++']