The solution explains

Since we will insert all numbers in a

HashMapand aMin Heap, this will take O(N*logN)O(N∗logN) where ‘N’ is the total input numbers.

But initializing a heap takes O(N). So why not initialize with all values at once?

In the end time complexity = O(N) + O(K Log K)

Right?