educative.io

Educative

Quick Clarification

for i in range(0, len(nums)):
  if not self.maxHeap or nums[i] <= -self.maxHeap[0]:
    heappush(self.maxHeap, -nums[i])
  else:
    heappush(self.minHeap, nums[i])

Why include this whole portion? Why not heapify the whole input array?