Javascript
\n/**\n * @param {number[]} stones\n * @return {number}\n */\nvar lastStoneWeight = function(stones) {\n    if(stones.length < 2) return stones;\n    while(ston
```\n/**\n * @param {number[]} stones\n * @return {number}\n */\nvar lastStoneWeight = function(stones) {\n    if(stones.length < 2) return stones;\n    while(stones.length > 1){\n        let index1 = stones.indexOf(Math.max(...stones));\n        let stone1 = stones.splice(index1,1);\n        let index2 = stones.indexOf(Math.max(...stones));\n        let stone2 = stones.splice(index2,1);\n        stones.push(stone1-stone2);        \n    }\n    return stones;\n};\n```
[]