Java || Greedy || sorting || Why greedy works here??
"You can arrange for the planet to collide with the asteroids in any arbitrary order."\nFirst we try colliding with the smallest asteroid to increase the chance
"You can arrange for the planet to collide with the asteroids **in any arbitrary order**."\nFirst we try colliding with the smallest asteroid to increase the chances of survival of planet.\n\n\n```\nclass Solution {\n    public boolean asteroidsDestroyed(int mass, int[] a) {\n        Arrays.sort(a);\n        //  mass of the planet is smaller than the smallest asteroid\n        if(mass < a[0]) return false;\n        long curr_planet_mass = mass;\n        for (int i = 0; i < a.length; i++) {\n            if (curr_planet_mass >= a[i]) {\n                curr_planet_mass += a[i];\n            } else {\n                return false;\n            }\n        }\n        return true;\n    }\n}
[]