If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________

Great Code ! However, I didn’t understand few things here.
1. Why are you starting at heap location 1 instead of 0.
2. During the initialization you are basically inserting the first element of every array into the heap. You will never come across ptrs[i] > n. Because you initialized ptrs[i] to be zero.

tutorialhorizon

1. We start with heap location 1 because ,
For any given node at position i:
– Its Left Child is at [2*i] if available.
– Its Right Child is at [2*i+1] if available.
So “i” cannot be 0. Read this link for more information. http://algorithms.tutorialhorizon.com/binary-min-max-heap/

2. ptrs[] start with 0 and goes till n-1. So when it becomes n, we will set the value as
Integer.max so it will never become greater than n.