primes. For each p, find the smallest non-negative integer a such that the bitwise OR of a and a + 1 equals p:
a | (a + 1) == p
If no such a exists, use -1. Return the answers in the same order as the numbers in primes.primes=[5, 19] → [4, 17]
4 OR 5 = 5, and nothing smaller works. For 19 (10011) the answer is 17 (10001): 17 OR 18 = 19.
primes=[2, 3] → [-1, 1]
a OR (a + 1) is always odd, so 2 has no answer: -1. For 3 it is 1, since 1 OR 2 = 3.
primes=[31, 23] → [15, 19]
primes[i] is primeprimes=[5, 19]
[4, 17]
Run checks the first 3 tests in your browser. Submit checks all 126 tests on the server, hidden ones included.