Sort the People

PHOTO EMBED

Sat Oct 08 2022 06:49:17 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    vector<string> sortPeople(vector<string>& names, vector<int>& heights) {
        int n=names.size();
        map<int,string> mp;
        for(int i=0;i<n;i++)
        {
            mp[heights[i]]=names[i];
        }
        vector<string> v;
        map<int,string>::iterator i;
        for(auto i=mp.begin();i!=mp.end();i++)
        {
            v.push_back(i->second);
            
        }
        reverse(v.begin(),v.end());
        return v;
    }
};
content_copyCOPY

https://leetcode.com/problems/sort-the-people/