哈希法 用map存储每个键值的出现次数,存完检查为众数直接返回该数,循环结束直接返回0 import java.util.*; public class Solution { public int MoreThanHalfNum_Solution(int [] array) { Map<Integer,Integer> map = new HashMap(); for(int e : array) { // 记录e出现次数 if(map.containsKey(e)) { map.put(e,map.get(e) + 1); } else { map.put(e, 1); } /...