SOLUTION INFO
C++ · main.cpp
class Solution {
public:
int lastStoneWeight(vector<int>& stones) {
priority_queue<int> q;
for(auto &i: stones)
q.push(i);
while(q.size() > 1 ){
int f = q.top();q.pop();
int s = q.top();q.pop();
if(f == s)continue;
q.push(f - s);
}
if(q.empty())return 0;
else return q.top();
}
};
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.