Easy java solution (Beats 74%)
Code\njava []\nclass Node {\n    int val;\n    int freq;\n    public Node(int val, int freq) {\n        this.val=val;\n        this.freq=freq;\n    }\n}\nclass 
# Code\n```java []\nclass Node {\n    int val;\n    int freq;\n    public Node(int val, int freq) {\n        this.val=val;\n        this.freq=freq;\n    }\n}\nclass MajorityChecker {\n    Node[] seg;\n    int n;\n    int[] arr;\n    Map<Integer, List<Integer>> mp;\n\n    public MajorityChecker(int[] arr) {\n        n=arr.length;\n        this.arr=arr;\n        seg=new Node[4*n];\n        mp=new HashMap<>();\n        build(0,0,n-1);\n    }\n\n    private void build(int idx, int start, int end) {\n        if(start==end) {\n            seg[idx]=new Node(arr[start],1);\n            List<Integer> list=mp.getOrDefault(arr[start], new ArrayList<>());\n            list.add(start);\n            mp.put(arr[start],list);\n            return;\n        }\n        int mid=(start+end)/2;\n        build(2*idx+1,start,mid);\n        build(2*idx+2,mid+1,end);\n        Node left=seg[2*idx+1];\n        Node right=seg[2*idx+2];\n        if(left.val==right.val) seg[idx]=new Node(left.val,left.freq+right.freq);\n        else if(left.freq>=right.freq) seg[idx]=new Node(left.val,left.freq-right.freq);\n        else seg[idx]=new Node(right.val,right.freq-left.freq);\n    }\n    \n    public int query(int left, int right, int threshold) {\n        Node node=query(0,0,n-1,left,right);\n        List<Integer> list=mp.getOrDefault(node.val,new ArrayList<>());\n        int l=Collections.binarySearch(list,left);\n        if(l<0) {\n            l*=(-1);\n            l--;\n        }\n        int r=Collections.binarySearch(list,right);\n        if(r<0) {\n            r*=(-1);\n            r-=2;\n        }\n        return (r-l+1)>=threshold?node.val:-1;\n    }\n\n    private Node query(int idx, int start, int end, int left, int right) {\n        if(start>right || end<left) return new Node(0,0);\n        if(start>=left && end<=right) return seg[idx];\n        int mid=(start+end)/2;\n        Node l=query(2*idx+1,start,mid,left,right);\n        Node r=query(2*idx+2,mid+1,end,left,right);\n        if(l.val==r.val) return new Node(l.val,l.freq+r.freq);\n        else if(l.freq>=r.freq) return new Node(l.val,l.freq-r.freq);\n        return new Node(r.val,r.freq-l.freq);\n    }\n}\n\n/**\n * Your MajorityChecker object will be instantiated and called as such:\n * MajorityChecker obj = new MajorityChecker(arr);\n * int param_1 = obj.query(left,right,threshold);\n */\n```
['Segment Tree', 'Java']