We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Any time you insert an element, create a new key for that element, with the value being the index in the array where that element is stored. Every time you swap elements, you update the indices in the dictionary. When you remove an element from the heap, simply delete that key from the dictionary.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →
Any time you insert an element, create a new key for that element, with the value being the index in the array where that element is stored. Every time you swap elements, you update the indices in the dictionary. When you remove an element from the heap, simply delete that key from the dictionary.