Skip to content

Commit 50bfe34

Browse files
committed
leetcode_1046
1 parent b1cf44d commit 50bfe34

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

1046_Last_Stone_Weight.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
int lastStoneWeight(vector<int>& stones) {
4+
while(stones.size()>1){
5+
sort(stones.begin(), stones.end(), greater<int>());
6+
stones[1] = (stones[0]-stones[1]);
7+
stones.erase(stones.begin());
8+
}
9+
return stones[0];
10+
}
11+
};

0 commit comments

Comments
 (0)