Kotlin: Priority Queue
Code\n\nclass Solution {\n    fun lastStoneWeight(stones: IntArray): Int {\n        val h = PriorityQueue<Int> { a, b -> b.compareTo(a) }\n        stones.forEac
# Code\n```\nclass Solution {\n    fun lastStoneWeight(stones: IntArray): Int {\n        val h = PriorityQueue<Int> { a, b -> b.compareTo(a) }\n        stones.forEach { h.add(it) }\n\n        while (h.size > 1) { \n            h.add(h.poll() - h.poll())\n        }\n \n        return h.poll()\n    }\n}\n```
['Heap (Priority Queue)', 'Kotlin']