commit 0e1dfd353f8bc5651de0d118869a6e534bba79c4
parent 0dc2bebb110f3e9c1e561c9ee1d7f8890543d389
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Tue, 21 May 2024 16:06:07 +0200
1 Random Problem
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Problems/2126.cpp b/Problems/2126.cpp
@@ -0,0 +1,14 @@
+class Solution {
+ public:
+ bool asteroidsDestroyed(int mass, vector<int> &asteroids) const {
+ sort(begin(asteroids), end(asteroids));
+
+ for (const int num : asteroids) {
+ if (num > mass) return false;
+ if (mass > 1e5) break;
+ mass += num;
+ }
+
+ return true;
+ }
+};
diff --git a/README.md b/README.md
@@ -1031,6 +1031,7 @@ for solving problems.
| 2115 | Medium | [Find All Possible Recipes from Given Supplies](Problems/2115.cpp) |
| 2120 | Medium | [Execution of All Suffix Instructions Staying in a Grid](Problems/2120.cpp) |
| 2125 | Medium | [Number of Laser Beams in a Bank](Problems/2125.cpp) |
+| 2126 | Medium | [Destroying Asteroids](Problems/2126.cpp) |
| 2130 | Medium | [Maximum Twin Sum of a Linked List](Problems/2130.cpp) |
| 2131 | Medium | [Longest Palindrome by Concatenating Two Letter Words](Problems/2131.cpp) |
| 2134 | Medium | [Minimum Swaps to Group All 1's Together II](Problems/2134.cpp) |