Skip to content

Commit 403b7e2

Browse files
committed
Runtime: 263 ms (Top 83.31%) | Memory: 102.6 MB (Top 92.47%)
1 parent fc019d5 commit 403b7e2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
// Runtime: 263 ms (Top 83.31%) | Memory: 102.6 MB (Top 92.47%)
12
class Solution {
23
public:
34
bool asteroidsDestroyed(int mass, vector<int>& asteroids) {
4-
5+
56
int n = asteroids.size();
67
sort(begin(asteroids), end(asteroids));
7-
8+
89
long long planetMass = mass;
9-
10+
1011
for(auto& asteroid : asteroids) {
11-
if(planetMass < asteroid) return false;
12-
planetMass += asteroid;
12+
if(planetMass < asteroid) return false;
13+
planetMass += asteroid;
1314
}
1415
return true;
1516
}
16-
};
17+
};

0 commit comments

Comments
 (0)