🚨 | Not a Medium Ques | Basic Sorting & Greedy Implementation | JAVA
1. Runtime: 40 ms, faster than 60.00% of Java online submissions for Destroying Asteroids.\n 2. Memory Usage: 129.5 MB, less than 20.00% of Java online submissi
* **1. Runtime: 40 ms, faster than 60.00% of Java online submissions for Destroying Asteroids.**\n* **2. Memory Usage: 129.5 MB, less than 20.00% of Java online submissions for Destroying Asteroids.**\n\n*In the given question, the confusing part was that we were given to choose the asteroids in any arbitrary order. We can just traverse one by one on asteroids array and return "false" if mass couldn\'t destroy the asteroid. Similarly for the opposite scenario.*\n\n```java\nclass Solution {\n    public boolean asteroidsDestroyed(int mass, int[] asteroids) {\n        \n        Arrays.sort(asteroids);\n        for(int i = 0; i<asteroids.length; i++)\n        {\n            if(mass > 10000000)\n                return true;\n            if(mass < asteroids[i])\n                return false;\n            mass += asteroids[i];\n        }\n        \n        return true;\n        \n    }\n}
['Greedy', 'Java']