simple C++ sort&unordered_map

  • 0
        vector<string> findRelativeRanks(vector<int>& nums) {
            vector<string> res;
            vector<int> copy = nums;
            sort(copy.begin(), copy.end(), greater<int>());
            unordered_map<int,int> um;
            for(int i=0;i<copy.size();i++) {
                um[copy[i]] = i;
            const vector<string> medals = {"Gold Medal", "Silver Medal", "Bronze Medal"};
            for(int num:nums) {
                int i=um[num];
            return res;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.