1538. Guess the Majority in a Hidden Array

An opaque binary array arr has length n, where every element is 0 or 1. You may not inspect the array directly. Instead, an ArrayReader exposes query(a, b, c, d) for four ordered, distinct indices 0 <= a < b < c < d < n. The query returns 4 when all four bits are equal, 2 when exactly three of the four bits are equal, and 0 when two bits are 0 and two bits are 1.

Return the index of any bit value that occurs strictly more than n / 2 times, or -1 when the hidden array is tied. You may make at most 2 * n queries. The executable contract preserves the opaque reader model and does not expose a direct array.

Examples
Input: [1,2,2,2,2,2]
Output: 1
Hints
Related Problems

1538. Guess the Majority in a Hidden Array

An opaque binary array `arr` has length `n`, where every element is `0` or `1`. You may not inspect the array directly. Instead, an `ArrayReader` exposes `query(a, b, c, d)` for four ordered, distinct indices `0 <= a < b < c < d < n`. The query returns `4` when all four bits are equal, `2` when exactly three of the four bits are equal, and `0` when two bits are `0` and two bits are `1`.