标签:ast turn int sort nbsp minus solution one while
class Solution { public int lastStoneWeight(int[] stones) { int len = stones.length; int i = len -1; int minus = 0; int remain = len; if(stones.length ==1){ return stones[0]; } else { Arrays.sort(stones); do{ if(stones[i]==stones[i-1]){ stones[i] = 0; stones[i-1] = 0; remain = remain -2; } else{ stones[i-1]= stones[i]-stones[i-1]; stones[i]=0; remain = remain -1; } Arrays.sort(stones); } while(remain >1); return stones[len-1]; } } }
(Easy) Last Stone Weight LeetCode
标签:ast turn int sort nbsp minus solution one while
原文地址:https://www.cnblogs.com/codingyangmao/p/11278051.html