Java boyer-moore O(N) solution
java\nimport java.util.*;\nclass MajorityChecker {\n\n  private int[] arr;\n\n  public MajorityChecker(int[] arr) {\n    this.arr = arr;\n  }\n  \n  public int 
```java\nimport java.util.*;\nclass MajorityChecker {\n\n  private int[] arr;\n\n  public MajorityChecker(int[] arr) {\n    this.arr = arr;\n  }\n  \n  public int query(int left, int right, int threshold) {\n    int m = -1, cnt = 0;\n    for (int i = left; i <= right; i++) {\n      if (cnt == 0) {\n        m = arr[i];\n        cnt++;\n        continue;\n      }\n      if (arr[i] == m) cnt++;\n      else cnt--;\n    }\n    cnt = 0;\n    for (int i = left; i <= right; i++) {\n      if (arr[i] == m) cnt++;\n    }\n    return cnt >= threshold ? m : -1;\n  }\n}\n```
[]