Simple C++ || Sorting and greedy approach
1.Sorting the asteroids vector in increasing order \n2. Checking if any moment the mass of the planet is less than the asteroid then returning false;\n3.Using l
1.Sorting the asteroids vector in increasing order \n2. Checking if any moment the mass of the planet is less than the asteroid then returning false;\n3.Using long long int in order to avoid overflow.\n\n\tbool asteroidsDestroyed(int mass, vector<int>& asteroids) {\n        \n        //Using long long int to avoid overflow\n        long long int m=mass;\n        \n        sort(asteroids.begin(),asteroids.end());   //sorting the mass of the asteroids in increasing order.\n       \n        //checking if mass of the planet is greater than asteroid then adding the mass in the planet else returning false\n        \n        for(int i=0;i<asteroids.size();i++){\n        \n            if(m>=asteroids[i])\n                m+=asteroids[i];\n            else\n                return false;\n            \n        }\n        return true;\n    }
['Greedy', 'C', 'Sorting']