C++ vector 100% time and space
\nclass Solution {\npublic:\n    int lastStoneWeight(vector<int>& stones) {\n        while(stones.size() > 1){\n            sort(stones.begin(),stones.end(),gre
```\nclass Solution {\npublic:\n    int lastStoneWeight(vector<int>& stones) {\n        while(stones.size() > 1){\n            sort(stones.begin(),stones.end(),greater<int>());\n            if(stones[0] == stones[1])\n                stones.erase(stones.begin(),stones.begin()+2);\n            else{\n                stones.push_back(abs(stones[0] - stones[1]));\n                stones.erase(stones.begin(),stones.begin()+2);         \n            }\n        }\n        if(!stones.empty())\n            return stones[0];\n        return 0;\n    }\n};\n```
['C', 'C++']