public class Solution {
    public static int MoreThanHalfNum_Solution(int [] array) {
        int len=array.length;
        int times=len/2;
        int res=0;
        HashMap<Integer,Integer> maps=new HashMap<>();
        for(int i=0;i<len;i++){
            maps.put(array[i], maps.getOrDefault(array[i], 0)+1);
            if(maps.get(array[i])>times){
                res=array[i];
                break;
            }
        }
        return res;
    }
}