Skip to content

Instantly share code, notes, and snippets.

@Israel-Miles
Created September 11, 2021 21:22
Show Gist options
  • Save Israel-Miles/86cd41da38899becb8d4d2eca2f138ab to your computer and use it in GitHub Desktop.
Save Israel-Miles/86cd41da38899becb8d4d2eca2f138ab to your computer and use it in GitHub Desktop.
func pop(heap *[]int) []int {
root := (*heap)[0]
n := len(*heap)
lastElement := (*heap)[n - 1]
(*heap)[0] = lastElement
*heap = (*heap)[:n-1]
heapify(heap, 0)
return root
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment