JavaScript using MaxPriorityQueue
Finally, there\'s a Max/MinPriorityQueue for JavaScript!\n\nadd -> enqueue( )\nremove -> dequeue( )\nhighest number (peek) -> front( )\n.element -> actual value
Finally, there\'s a Max/MinPriorityQueue for JavaScript!\n\nadd -> enqueue( )\nremove -> dequeue( )\nhighest number (peek) -> front( )\n.element -> actual value\n\n```\nvar lastStoneWeight = function(stones) {\n    const m = new MaxPriorityQueue()\n    for(const w of stones) m.enqueue(w)\n    \n    while(m.size() > 1){\n        const diff = m.dequeue().element - m.dequeue().element\n        if(diff > 0) m.enqueue(diff)\n    }\n \n    return m.size() === 0 ? 0 : m.front().element\n};\n```
['JavaScript']