Tap here to switch tabs
Problem
Submissions

Problem: Construct the Minimum Bitwise Array II

med
30 min
Try to solve the Construct the Minimum Bitwise Array II problem.

Statement

You are given an array nums consisting of prime integers.

You need to construct an array ans of the same length, where ans[i] is the smallest non negative integer that satisfies ans[i] | (ans[i] + 1) == nums[i], where | denotes the bitwise OR operator. If no such value exists for a given index i, set ans[i] to −1-1.

Return the array ans.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 2≤2 \leq nums[i] ≤109\leq 10^9

  • nums[i] is a prime number.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Construct the Minimum Bitwise Array II

med
30 min
Try to solve the Construct the Minimum Bitwise Array II problem.

Statement

You are given an array nums consisting of prime integers.

You need to construct an array ans of the same length, where ans[i] is the smallest non negative integer that satisfies ans[i] | (ans[i] + 1) == nums[i], where | denotes the bitwise OR operator. If no such value exists for a given index i, set ans[i] to −1-1.

Return the array ans.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 2≤2 \leq nums[i] ≤109\leq 10^9

  • nums[i] is a prime number.