Bisection - Least Runtime Solution
\nclass MajorityChecker:\n\n    def __init__(self, arr: List[int]):\n        self.idx = defaultdict(list)\n        for i, num in enumerate(arr):\n            se
```\nclass MajorityChecker:\n\n    def __init__(self, arr: List[int]):\n        self.idx = defaultdict(list)\n        for i, num in enumerate(arr):\n            self.idx[num] += [i]\n        self.idx = sorted(self.idx.items(), key = lambda x: -len(x[1]))\n\n    def query(self, left: int, right: int, threshold: int) -> int:\n        for num, idxs in self.idx:\n            if len(idxs) >= threshold:\n                l_idx = bisect.bisect_left(idxs, left)\n                r_idx = bisect.bisect(idxs, right)\n                if r_idx - l_idx >= threshold:\n                    return num\n            else:\n                break\n        return -1\n        \n\n\n# Your MajorityChecker object will be instantiated and called as such:\n# obj = MajorityChecker(arr)\n# param_1 = obj.query(left,right,threshold)\n```
[]