Simple & Easy to Understand Code Along with Intuition & Approach Explained
Intuition\n Describe your first thoughts on how to solve this problem. \nWe have to basically destroy all the asteroids and it can be done simply if planet has 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have to basically destroy all the asteroids and it can be done simply if planet has higher mass than my asteroid. So, simple thought comes to mind is that intially i go for smallest asteroid and destroy it which in turn add some more mass to my planet which may help me to destroy the next asteroid.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Sort the given asteroid array in increase order.\n2. Start comapring all the elements of array with mass\n- if mass is less than asteroid mass then **return false**.\n- else add asteroid mass into planets mass.\n3. And at the end **return true**.\n\n\n# Code\n```\nclass Solution {\npublic:\n    bool asteroidsDestroyed(int mass, vector<int>& asteroids) {\n        sort(asteroids.begin() , asteroids.end()) ;\n        long long int m = mass ;\n        for(int i = 0 ; i < asteroids.size() ; i++){\n            if(m < asteroids[i]) return false;\n            m += asteroids[i] ;\n        }\n        return true ;\n    }\n};\n```
['C', 'Python', 'C++', 'Java']