Simple minheapify and maxheapify solution for int arrays