Please refer | language-java


#1

`public int majorityElement(final int[] A) {
HashMap<Integer,Integer> map=new HashMap<>();

    for(int i=0;i<A.length;i++)
    {
        if(map.containsKey(A[i]))
        {
            map.put(A[i],map.get(A[i])+1);
        }
        else
        {
            map.put(A[i],1);
        }
    }
   int floor= (int) (Math.floor(A.length/2)+1.0);
    //Integer,Integer
    Set<Map.Entry<Integer,Integer>> set = map.entrySet();
    for(Map.Entry<Integer,Integer> e: set)
    {
        if(e.getValue()>=floor)
            return e.getKey();
    }
    return -1; 
}`