SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string electionWinner(vector<string> votes) {
  2.     string s;
  3.     int win = 0;
  4.     map<string, int> m;
  5.     for (auto vote : votes ){
  6.         m[vote]++;
  7.     }
  8.  
  9.     for (auto it = m.begin(); it != m.end(); it++){
  10.         if (it->second >= win){
  11.             s = it->first;
  12.             win = it->second;
  13.         }
  14.     }
  15.  
  16.     return s;
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top