O(n) solution using Min Heap C++


#1
priority_queue <int, vector<int>, greater<int> > pq;
for(int i=0;i<A.size();i++)
{
    pq.push(A[i]);
}
for(int i=0;i<A.size();i++)
{
    A[i]=pq.top();
    pq.pop();
}