import java.util.*;

public class Solution {

    public int MoreThanHalfNum_Solution(int [] numbers) {
         if (numbers.length==1){
            return numbers[0];
        }
        int ret = 0;
        int n = numbers.length/2+1;//注意四舍五入
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < numbers.length; i++) {
            map.put(numbers[i],map.getOrDefault(numbers[i],0)+1);
        }
        for(int x :numbers){
            if (map.get(x)>=n ){
               ret = x;
            }
        }

        return ret;
        
    }
}