[Golang] MaxHeap
Complexity\n- Time complexity:\nO(NlogN)\n\n- Space complexity:\nO(N)\n\n# Code\n\nfunc lastStoneWeight(stones []int) int {\n    maxHeap := &MaxHeap{}\n\n    fo
# Complexity\n- Time complexity:\nO(NlogN)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nfunc lastStoneWeight(stones []int) int {\n    maxHeap := &MaxHeap{}\n\n    for _, stone := range stones {\n        heap.Push(maxHeap, stone)\n    }\n\n    for maxHeap.Len() > 1 {\n        stone1 := heap.Pop(maxHeap).(int)\n        stone2 := heap.Pop(maxHeap).(int)\n\n        if stone1 != stone2 {\n            heap.Push(maxHeap, stone1 - stone2)\n        }\n    }\n\n    res := 0\n    if maxHeap.Len() == 1 {\n        res = (*maxHeap)[0]\n    }\n    return res\n}\n\ntype MaxHeap []int\n\nfunc (h MaxHeap) Len() int           { return len(h) }\nfunc (h MaxHeap) Less(i, j int) bool { return h[i] > h[j] }\nfunc (h MaxHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }\n\nfunc (h *MaxHeap) Push(x interface{}) {\n    *h = append(*h, x.(int))\n}\n\nfunc (h *MaxHeap) Pop() interface{} {\n    x := (*h)[len(*h)-1]\n\t*h = (*h)[:len(*h)-1]\n\treturn x\n}\n```
['Go']