Problem: Hostel Visit
My Solution: https://ide.codingblocks.com/s/41602
Please help me debug my code. One of the two test cases is failing.
Problem: Hostel Visit
My Solution: https://ide.codingblocks.com/s/41602
Please help me debug my code. One of the two test cases is failing.
Code will work with max heap of only size k. try to optimize it.
NEED
Make heap of size k …
For INSERTING TYPE 1 QUERY
After inserting first k values
whenever any element with value greater than root of heap comes it will discard it cozz it can never contribute in your answer .
otherwise delete max root and insert new value in the heap so that total size will be k.
FOR TYPE 2 QUERY
root of heap is required answer.
Try to analyze this approach.
Hit like if u get my approach for your code.