Java Solution
\nclass MajorityChecker {\n    Map<Integer, List<Integer>> map = new HashMap<>();\n    int[] arr;\n\n    public MajorityChecker(int[] arr) {\n        this.arr =
```\nclass MajorityChecker {\n    Map<Integer, List<Integer>> map = new HashMap<>();\n    int[] arr;\n\n    public MajorityChecker(int[] arr) {\n        this.arr = arr;\n        for (int i = 0; i < arr.length; i++) {\n            map.putIfAbsent(arr[i], new ArrayList<>());\n            map.get(arr[i]).add(i);\n        }\n    }\n\n    private int getOccurrence(int left, int right, int a) {\n        List<Integer> list = map.get(a);\n        int i = Collections.binarySearch(list, left);\n        if (i < 0) i = ~i;\n        if (i == list.size()) return 0;\n        int j = Collections.binarySearch(list, right);\n        if (j < 0) j = ~j - 1;\n        return j - i + 1;\n    }\n\n    private int getRandomNum(int l, int r) {\n        Random rand = new Random();\n        return rand.nextInt(r - l + 1) + l;\n    }\n\n    public int query(int left, int right, int threshold) {\n        for (int i = 0; i < 10; i++) {\n            int a = arr[getRandomNum(left, right)];\n            if (getOccurrence(left, right, a) >= threshold)\n                return a;\n        }\n        return -1;\n    }\n}\n```
[]