Lowkey trivial. Solved it in 1 minute. It’s just a clean heuristic problem, kinda like May 22nd’s Daily Problem, LC 1665: Minimum Initial Energy to Finish Tasks except the heuristic is even easier to see.
My Solution:
class Solution:
def asteroidsDestroyed(self, mass: int, asteroids: List[int]) -> bool:
asteroids.sort() # sort lo to hi
# heuristic: collide with the smallest asteroids first,
# accumulate mass,
# and just keep goin.
curr = mass
for a in asteroids:
if curr >= a:
curr += a
continue
return False
return True