c++vectorstlpriority-queue

Vectors to Priority_queue in STL c++


How to convert a vector v to priority_queue pq? Like we can do as-

for(int i=0;i<(int)v.size();i++) pq.push(v[i]);

But is it possible to keep it more short and concise?


Solution

  • priority_queue<int>pq(begin(stones),end(stones));