intdominator(vector<int>arr){// stores the number with its countunordered_map<int,int>numCount;// if count of any number becomes more than arr.size()/2// then return that numberfor(intnum:arr){if(++numCount[num]>arr.size()/2)returnnum;}// if no number has count more than arr.size()/2// then return -1return-1;}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
C++ solution