C++ O(nlogn)   One of the easiest Greedy Solutions 🔥
We can just sort the array first to get the lowest weighted asteroids first and add its weight so on...\nif we reach till the end of the sorted array...we can s
We can just sort the array first to get the lowest weighted asteroids first and add its weight so on...\nif we reach till the end of the sorted array...we can say that we have successfully destroyed all the asteroids(as the most weighted asteroid is at the end)... otherwise if in between while traversing if we found that the mass of the planet is less than  the mass of the asteroid, we can simply return false without checking further\n\n```\nclass Solution {\npublic:\n    bool asteroidsDestroyed(int mass, vector<int>& ast) {\n        vector<int>nums(ast);\n        sort(nums.begin(), nums.end());\n        long long mas = mass;\n        for(int i =0. ;i < ast.size() ; i++){\n            if(nums[i]<=mas){\n                mas += nums[i];\n            }\n            else{\n                return false;\n            }\n        }\n        return true;\n    }\n};\n```
['Greedy', 'C', 'Sorting']