public class Solution {
public int MoreThanHalfNum_Solution(int [] array) {
HashMap<Integer,Integer> map=new HashMap<>();
for(int i=0;i<array.length;i++){
if(!map.containsKey(array[i])){
map.put(array[i],1);
}else{
int count=map.get(array[i]);
map.put(array[i],++count);
}
int time=map.get(array[i]);
if(time>array.length>>1)
return array[i];
}
return 0;
}
}