link to code: https://ide.codingblocks.com/s/258963
Can you help me find the time complexity of my code and also is there a better solution than this?
link to code: https://ide.codingblocks.com/s/258963
Can you help me find the time complexity of my code and also is there a better solution than this?
time compexity is O(n)
this solution is good and O(n) time complexity is fine for this question
How is it O(N)?
What if the input was n = 1e7 and k = 3.
and in the input after ~1e7 query of type 1, I get a query of type 2. then i’ll be removing elem from heap till its size is 3. it then will not be O(n * k)?
then it should be O(n+k)== O(n)