Codility - Dominator

RESULT

import java.util.*;

class Solution {
    public int solution(int[] A) {
        Map<Integer, Integer> map = new HashMap<>();
        int dominator = -1;
        
        for (int i=0; i<A.length; i++) {
            map.put(A[i], map.getOrDefault(A[i], 0) + 1);
            if (map.get(A[i]) > A.length / 2) {
                dominator = i;
                break;
            }
        }
        
        return dominator;
    }
}