Beats 88%, Simple and Easy to Understand
Intuition\n Describe your first thoughts on how to solve this problem. \nWe have to find an asteroid with least mass that can destroy the planet.\n# Approach\n 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have to find an asteroid with least mass that can destroy the planet.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe first sort the asteroid according to increasing order of their masses.\n\nThen we keep on iterating till we find an asteroid whose mass is greater than the mass of the planet.\n\nAlso, if the mass of the asteroid is less or equal to the planet, then we will add that mass to the mass of planet.\n\n**Note: We will need to declare a new mass variable for planet with a datatype of long.**\n\n\n# Code\n```\nclass Solution {\npublic:\n    bool asteroidsDestroyed(int mass, vector<int>& asteroids) {\n        int n = asteroids.size();\n        long mass_new = mass;\n            \n        sort(asteroids.begin(),asteroids.end());\n        \n        for(int j = 0; j < n; j++){\n            if(asteroids[j] <= mass_new)\n                mass_new +=  asteroids[j];\n            else\n                return false;\n                \n        }\n        return true;\n        \n        \n    }\n};\n```
['C++']