values. Call a number x reachable if you can pick a non-empty set of elements of the array (each at most once) whose bitwise OR is exactly x.
Return the smallest positive integer that is not reachable.values=[1, 2, 6] → 4
You can get 1, 2, 3 = 1 | 2, 6 and 7 = 1 | 6. But 4 is out of reach: the only value with the 4s bit set is 6, and any OR including it is at least 6.
values=[3, 5] → 1
Even 1 is unreachable: the array has no 1, and every OR is at least 3.
values=[4, 1, 2, 8, 9] → 16
values=[1, 2, 6]
4
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.