We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc019d5 commit 403b7e2Copy full SHA for 403b7e2
scripts/algorithms/D/Destroying Asteroids/Destroying Asteroids.cpp
@@ -1,16 +1,17 @@
1
+// Runtime: 263 ms (Top 83.31%) | Memory: 102.6 MB (Top 92.47%)
2
class Solution {
3
public:
4
bool asteroidsDestroyed(int mass, vector<int>& asteroids) {
-
5
+
6
int n = asteroids.size();
7
sort(begin(asteroids), end(asteroids));
8
9
long long planetMass = mass;
10
11
for(auto& asteroid : asteroids) {
- if(planetMass < asteroid) return false;
12
- planetMass += asteroid;
+ if(planetMass < asteroid) return false;
13
+ planetMass += asteroid;
14
}
15
return true;
16
-};
17
+};
0 commit comments