Go || Two heap
\nThis problem similar to last week \nCheckout my other, use heap as well\nhttps://leetcode.com/problems/zero-array-transformation-ii/solutions/6053396/go-min-h
\nThis problem similar to last week \nCheckout my other, use heap as well\nhttps://leetcode.com/problems/zero-array-transformation-ii/solutions/6053396/go-min-heap/\n\n# Code\n```golang []\nfunc maxRemoval(nums []int, queries [][]int) int {\n\tslices.SortFunc(queries, func(a, b []int) int {\n\t\tif a[0] == b[0] {\n\t\t\treturn b[1] - a[1] \n\t\t}\n\t\treturn a[0] - b[0] \n\t})\n\n\tused := priorityqueue.New[int]() \n\tq := priorityqueue.NewWith(func(x, y int) int { return y - x }) \n\n\tqueryIndex := 0\n\tusedCount := 0\n\n\tfor i := range nums {\n\t\tfor !used.Empty() {\n\t\t\ttop, _ := used.Peek()\n\t\t\tif i <= top {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tused.Dequeue()\n\t\t}\n\n\t\tfor queryIndex < len(queries) {\n\t\t\tstart, end := queries[queryIndex][0], queries[queryIndex][1]\n\t\t\tif end < i {\n\t\t\t\tqueryIndex++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif start > i {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tq.Enqueue(end)\n\t\t\tqueryIndex++\n\t\t}\n\n\t\tfor used.Size() < nums[i] {\n\t\t\ttop, ok := q.Peek()\n\t\t\tif !ok || top < i {\n\t\t\t\treturn -1\n\t\t\t}\n\t\t\tused.Enqueue(top)\n\t\t\tq.Dequeue()\n\t\t\tusedCount++\n\t\t}\n\t}\n\n\treturn len(queries) - usedCount\n}\n\n```
['Heap (Priority Queue)', 'Go']