3314. Construct the Minimum Bitwise Array I
You are given an array
nums
consisting ofn
prime integers.You need to construct an array
ans
of lengthn
, such that, for each indexi
, the bitwiseOR
ofans[i]
andans[i] + 1
is equal tonums[i]
, i.e.ans[i] OR (ans[i] + 1) == nums[i]
.Additionally, you must minimize each value of
ans[i]
in the resulting array.If it is not possible to find such a value for
ans[i]
that satisfies the condition, then setans[i] = -1
.A prime number is a natural number greater than 1 with only two factors, 1 and itself.
1 | class Solution { |