Merge k sorted arrays

I didn’t understand the last question.
if(y+1<arr.size).
can you explains this with help of an example

@dips123deepali_c25f140838182212,

a1[] = {1,2}
a2[] = {4,5}

you’ll insert 1 and 4 initially then pop so 1 comes out and now u check if u have reached the end if not then insert next of that so next to 1 is 2. Again pop so2 comes out again u check if there’s something after 2 in a1 u find no u have reached the end
so u don’t insert this is exactly what that code checks

if you are at last element than you cant insert into priority queue

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.