C++ solution || Using Priority queue || Beginner friendly
I have used unordered map instead of ordered map because insertion of an element in unordered map is O(1) time complexity.\n\n vector<int> frequencySort(vector<
``` I have used unordered map instead of ordered map because insertion of an element in unordered map is O(1) time complexity.```\n```\n vector<int> frequencySort(vector<int>& a) {\n        int n=a.size();\n        vector<int>v;\n        unordered_map<int,int>mp;\n        for(int i=0;i<n;i++)\n            mp[a[i]]++;\n        priority_queue<pair<int,int>>pq;\n        for(auto it:mp)\n            pq.push({-(it.second),(it.first)});    // (-) sign is used to make it a min heap.\n         while(!pq.empty()) {  \n             int num1= -pq.top().first; \n\t\t\t int num2 = pq.top().second; \n             while(num1--)\n\t\t\t  v.push_back(num2);\n\n\t\t\tpq.pop();\n\t\t}\n        return v;\n    }\n```\n```If you like my approach then please upvote me.```
[]