Before we start popping off k elements from the min heap, doesn’t it also require O(m * logm) to build the initial min heap?
1 Like
Yeah. It requires time complexity of O(m*logm). And if we add these two values then it becomes nearly equal to O(2klogm). Here we can ignore constant and then it becomes O(klogm).