Gary Lai
  • Home
  • About
Sign in Subscribe

2126. Destroying Asteroids

Last updated on  Apr 2, 2025

2126. Destroying Asteroids

class Solution:
    def asteroidsDestroyed(self, mass: int, asteroids: List[int]) -> bool:
        asteroids.sort()

        for asteroid in asteroids:
            if mass >= asteroid:
                mass += asteroid
            else:
                return False
        return True
Previous 901. Online Stock Span
Next 2294. Partition Array Such That Maximum Difference Is K
Gary Lai © 2025
  • Sign up
Powered by Ghost