am i doing these question under the given constraint ,
1.https://practice.geeksforgeeks.org/problems/kth-smallest-element5545-1587115620/1
code–>
https://ide.codingblocks.com/s/381744
2.https://practice.geeksforgeeks.org/problems/k-largest-elements4206/1
code–>
https://ide.codingblocks.com/s/381745
3.https://practice.geeksforgeeks.org/problems/third-largest-element/1
code–>
https://ide.codingblocks.com/s/381751
and how should i know that i am doing under the given constraint
i know that insertion deletion and top takes 0(logn) o(logn) and o(1)
TIME COMPLEXITY OF THE SOLUTION
hey , sorry for the delay
you want to know how check complexity of your code?
yes , was i doing these questions under the time constraint and how do i calculate the complexity for these type of question?
k insertion in heap is O(logk)
n iteration of the array o(n)
so what will be the time complexity?
=o(n+logk)
is that right?
yes When there are consecutive loops, we calculate time complexity as sum of time complexities of individual loops.
you can go through this once too .time complexities are very important