values and a number goal. A stretch is a non-empty run of consecutive elements of the array.
Return the number of stretches whose bitwise AND over all elements is exactly goal. Stretches with the same values but at different positions count separately.values=[7, 6, 14, 6], goal=6 → 8
The AND is 6 for [6], [6], [7, 6], [6, 14], [14, 6], [6, 14, 6], [7, 6, 14] and [7, 6, 14, 6]: 8 stretches.
values=[3, 5, 3], goal=1 → 3
3 AND 5 = 1, so [3, 5], [5, 3] and [3, 5, 3] work; the single elements are 3 or 5.
values=[4, 8], goal=2 → 0
values) ≤ 10⁵values[i], goal ≤ 10⁹values=[7, 6, 14, 6], goal=6
8
Run checks the first 3 tests in your browser. Submit checks all 128 tests on the server, hidden ones included.