Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int NrMinMaxAp(vector<int> &a)
- {
- map<int, int> M;
- int maxfr=0, minnr=INT_MAX;
- for(int i=0; a[i]; i++)
- {
- if(M.find(a[i]) == M.end())
- M[a[i]] = 1;
- else
- {
- M[a[i]]++;
- if(M[a[i]]>maxfr)
- {
- maxfr=M[a[i]];
- minnr=a[i];
- }
- else if(M[a[i]]==maxfr)
- {
- if(a[i]<minnr)
- minnr=a[i];
- }
- }
- }
- return minnr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement