[Java/Python 3] Sort then apply greedy algorithm.
java\n    public boolean asteroidsDestroyed(int mass, int[] asteroids) {\n        long m = mass;\n        Arrays.sort(asteroids);\n        for (int ast : astero
```java\n    public boolean asteroidsDestroyed(int mass, int[] asteroids) {\n        long m = mass;\n        Arrays.sort(asteroids);\n        for (int ast : asteroids) {\n            if (m < ast) {\n                return false;\n            }\n            m += ast;\n        }\n        return true;\n    }\n```\nIn case you do NOT like using `long`, we can use the constraints: `1 <= asteroids[i] <= 10^5`: once mass is greater than all asteroids, we can conclude all can be destroyed.\u3000-- inspired by **@Zudas**.\n\n```java\n    public boolean asteroidsDestroyed(int mass, int[] asteroids) {\n        Arrays.sort(asteroids);\n        for (int ast : asteroids) {\n            if (mass < ast) {\n                return false;\n            }else if (mass > 100_000) { // now we can conclude all can be destroyed.\n                return true;\n            }\n            mass += ast;\n        }\n        return true;\n    }\n```\n```python\n    def asteroidsDestroyed(self, mass: int, asteroids: List[int]) -> bool:\n        for a in sorted(asteroids):\n            if mass < a:\n                return False\n            mass += a\n        return True\n```\n**Analysis:**\n\nTime: `O(n * log(n))`, space: `O(n)` - including sorting space.
['Java', 'Python3']