Heap using array list

Respected Sir,
As you had taught us to implement heap using arraylist but on competitive platform when I use same heap implementation I got TLE.
May b e its due to array list instead of array.
please tell efficient way to get rid of TLE.

@mr.excalibur22,

There might be some other approach for optimization, because if you are using heaps, it should not give a TLE.

You can try and use reader class for input and output because Scanner is very slow as compared to it.

Template of reader class is attached. It is very fast and might give you an AC too.
https://ide.codingblocks.com/s/220903 here is a sample template for reader class. You can edit the main function and continue with your code as normal.

This is by far the fastest ways of taking input but is difficult to remember and is cumbersome in its approach. Although this is ultra fast, it is clearly not an easy method to remember.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.