---
title: "2126. Destroying Asteroids"
url: "https://laigary.com/interview/coding/2126-destroying-asteroids"
type: "note"
section: "coding"
date: "2025-04-02"
updated: "2025-04-02"
tags: ["Greedy"]
---

# 2126. Destroying Asteroids

[2126\. Destroying Asteroids](https://leetcode.com/problems/destroying-asteroids/)

```python
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

```
