educative.io

Explanation of Time Complexity for “Find the k Largest Elements in an Array”

We are calling buildMaxHeap() k times where each call to buildMaxHeap() takes O(n) time so, shouldn’t the overall time complexity be O(k*n)?

No, we are just calling the function k times but the time complexity of buildMaxHeap() that is O(n) will not be affected.