unordered_map
数组中出现次数超过一半的数字
http://www.nowcoder.com/questionTerminal/e8a1b01a2df14cb2b228b30ee6a92163
class Solution { public: int MoreThanHalfNum_Solution(vector<int> numbers) { unordered_map<int, int> m; int size = numbers.size(); for(int i=0;i<size;i++){ m[numbers[i]]++; if(m[numbers[i]]>size/2) return numbers[i]; } return 0; } };