saritapatel8770 / Leetcode-solutions

7 stars 46 forks source link

2418. Sort the People #22

Closed saritapatel8770 closed 2 years ago

saritapatel8770 commented 2 years ago

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

Indrajeet-S commented 2 years ago

@saritapatel8770 I want to solve this problem could you assign me

Indrajeet-S commented 2 years ago

@saritapatel8770 hey, solved this

Indrajeet-S commented 2 years ago

Hey @saritapatel8770 I solved this problem but when I was trying to access map's element then it was giving me an compiler error so I used different method. But could you tell me what was wrong in this?

the error was : Line 10: Char 33: error: no member named 'second' in 'std::__cxx11::basic_string' ans.push_back(mp[i].second);


1 error generated.

The code was : 
        map<int, string> mp;
        for(int i=0;i<names.size();i++){
            mp[heights[i]]= names[i];
        }
        vector<string> ans;
       for(int i=names.size()-1;i>=0;i--){
            ans.push_back(mp[i].second);  // here it is giving error 

        }
        return ans;        
    }
};
Indrajeet-S commented 2 years ago

@saritapatel8770 was my PR successfully merged? or it's invalid.. why so?

Indrajeet-S commented 2 years ago

Okay, got it I push empty file .. I forgot to save the file in vs code that's why this has happed .. could you give me another chaance

Indrajeet-S commented 2 years ago

hey could you check my PR now