You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution you can find the explanation here : https://youtu.be/poQPrHTMe08
int migratoryBirds(vector<int> arr) { map<int, int> mp; int cnt = 0, id; for(int i = 0; i < arr.size(); i++)mp[arr[i]]++; for(auto it = mp.begin(); it != mp.end(); it++){ if(it->second > cnt || (it->second == cnt && it->first < id)){ cnt = it->second; id = it->first; } } return id; }
Seems like cookies are disabled on this browser, please enable them to open this website
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution you can find the explanation here : https://youtu.be/poQPrHTMe08