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.
Build a minHeap using an array. This is all a priority queue is. A heap is fast because it takes O(1) time to access the min and O(logn) time to traverse the tree. A normal queue takes O(n) time to traverse it and O(n) to access the min.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jesse and Cookies
You are viewing a single comment's thread. Return to all comments →
Build a minHeap using an array. This is all a priority queue is. A heap is fast because it takes O(1) time to access the min and O(logn) time to traverse the tree. A normal queue takes O(n) time to traverse it and O(n) to access the min.