Tap here to switch tabs
Problem
Submissions

Problem: Construct the Minimum Bitwise Array I

Construct the Minimum Bitwise Array I transforms each prime in an array into the smallest nonnegative value whose bitwise OR with its next integer equals it, or returns negative one when impossible.

Statement

Given an array nums consisting of prime numbers, construct an array ans of the same length.

For each index i, ans[i] must be the minimum non negative integer such that ans[i] ext{ OR } (ans[i] + 1) = nums[i]. If no such integer exists for an 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] ≤1000\leq 1000

  • nums[i] is a prime number.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Construct the Minimum Bitwise Array I

Construct the Minimum Bitwise Array I transforms each prime in an array into the smallest nonnegative value whose bitwise OR with its next integer equals it, or returns negative one when impossible.

Statement

Given an array nums consisting of prime numbers, construct an array ans of the same length.

For each index i, ans[i] must be the minimum non negative integer such that ans[i] ext{ OR } (ans[i] + 1) = nums[i]. If no such integer exists for an 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] ≤1000\leq 1000

  • nums[i] is a prime number.