[LeetCode] Construct the Minimum Bitwise Array I

3314. Construct the Minimum Bitwise Array I

You are given an array nums consisting of n prime integers.

You need to construct an array ans of length n, such that, for each index i, the bitwise OR of ans[i] and ans[i] + 1 is equal to nums[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 set ans[i] = -1.

A prime number is a natural number greater than 1 with only two factors, 1 and itself.

Read more
[AtCoder] F - TransposeRead more
[AtCoder] F - Oddly SimilarRead more
[Codeforces] Round 969 (Div. 1) A. Iris and Game on the TreeRead more
[Codeforces] Round 969 (Div. 1) B. Iris and the TreeRead more
[Codeforces] Round 972 (Div. 2) C. Lazy NarekRead more
[Codeforces] Educational Round 169 (Rated for Div. 2) D. Colored PortalsRead more
[Hacker Cup 2024 Round 1] Problem D: Substitution CipherRead more
[Hacker Cup 2024 Round 1] Problem C: Substantial LossesRead more
[Hacker Cup 2024 Round 1] Problem B: Prime SubtractorizationRead more