Category : data-structures

I was trying to solve this problem in leetcode. problem: heap problem this is my code: class Solution { public: vector<string> findRelativeRanks(vector<int>& score) { priority_queue<pair<int,int>,vector<pair<int,int>>>mxheap; for(int i=0; i<score.size(); i++){ mxheap.push({score[i],i}); } vector<string>ans(score.size()); int place = 1; while(!mxheap.empty()){ switch(place){ case 1: ans[mxheap.top().second] = "Gold Medal"; mxheap.pop(); break; case 2: ans[mxheap.top().second] = "Silver Medal"; mxheap.pop(); break; case ..

Read more