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.
- Prepare
- Data Structures
- Heap
- QHEAP1
- Discussions
QHEAP1
QHEAP1
Sort by
recency
|
413 Discussions
|
Please Login in order to post a comment
For all those who are having trouble with the delete operation, I hope the following link can be helpful; https://en.wikipedia.org/wiki/Binary_heap#Delete
my code fail 2 test erorr time limit why :(((
I am confused by this problem. As best as I understand, the idea of the min-heap is that it is supposed to efficiently erase the top (minimum) element, but it is not supposed to be efficient at erasing an arbitrary element. On the other hand, I looked at other people's solutions, and they all implemented it using a set, which is not strictly speaking, correct because it would handle dublicate numbers differently. Nevertheless, the solution using a set passes all tests. Am I missing anything here?
in java i used a TreeSet
public static void main(String[] args) { Scanner s = new Scanner(System.in);
Why this is getting TLE, where as if I create a heap class and acces custom-made delete method which is actually self.heap.remove(element) is ok??