javascript greedy 226ms
Main idea: optimal arrangement is to phase smaller one each time.\n\nconst asteroidsDestroyed = (mass, a) => {\n    a.sort((x, y) => x - y);\n    let n = a.leng
Main idea: optimal arrangement is to phase smaller one each time.\n```\nconst asteroidsDestroyed = (mass, a) => {\n    a.sort((x, y) => x - y);\n    let n = a.length, sum = mass;\n    for (let i = 0; i < n; i++) {\n        if (sum >= a[i]) {\n            sum += a[i];\n        } else {\n            return false;\n        }\n    }\n    return true;\n};\n```
['Greedy', 'Sorting', 'JavaScript']