a few solutions
Sort the input array A to greedily consume the smallest first.\n\n---\n\nKotlin\n\nclass Solution {\n    fun asteroidsDestroyed(T: Int, A: IntArray): Boolean {\
Sort the input array `A` to greedily consume the smallest first.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n    fun asteroidsDestroyed(T: Int, A: IntArray): Boolean {\n        var t = T.toLong()\n        A.sort()\n        for (x in A) {\n            if (t < x)\n                return false\n            t += x\n        }\n        return true\n    }\n}\n```\n\n*Javascript*\n```\nlet asteroidsDestroyed = (t, A) => {\n    A.sort((a, b) => a - b);\n    for (let x of A) {\n        if (t < x)\n            return false;\n        t += x;\n    }\n    return true;\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def asteroidsDestroyed(self, t: int, A: List[int]) -> bool:\n        A.sort()\n        for x in A:\n            if t < x:\n                return False\n            t += x\n        return t\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using LL = long long;\n    using VI = vector<int>;\n    bool asteroidsDestroyed(int T, VI& A) {\n        LL t{ T };\n        sort(A.begin(), A.end());\n        for (auto x: A) {\n            if (t < x)\n                return false;\n            t += x;\n        }\n        return true;\n    }\n};\n```
[]