题目链接
class Solution {
public int lastStoneWeight(int[] stones) {
int len = stones.length;
if(len == 1){
return stones[0];
}
if(len == 2){
return Math.abs(stones[0] - stones[1]);
}
while(true){
Arrays.sort(stones);
if(stones[len - 2] == 0){
break;
}
stones[len - 1] = stones[len - 1] - stones[len - 2];
stones[len - 2] = 0;
}
return stones[len - 1];
}
}