Preview:
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;
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter