Join Ropes prblem

priority_queue<int, vector, greater> pq(ropes, ropes + n);

what exactly this line will initialize the queue

hello @sounakume,
priority_queue<int, vector, greater> pq(ropes, ropes + n);
this line takes ropes array and make a min heap using the elements of that array.

yeah that i understand, but whats with ropes+n, why are we passing that arg??

this first param is base address of the array (i.e arr)
and arr+n is the address next to n th element.
refer this -> http://www.cplusplus.com/reference/queue/priority_queue/priority_queue/

1 Like