3315. Construct the Minimum Bitwise Array II

You are given an array nums consisting of prime integers. Construct an array ans of the same length such that, for each index i, ans[i] | (ans[i] + 1) == nums[i]. Minimize each ans[i] independently. If no non-negative value satisfies the equation, set ans[i] to -1.

Examples
Input: [[2,3,5],7]
Output: [5,4,2]
Hints

3315. Construct the Minimum Bitwise Array II

You are given an array `nums` consisting of prime integers. Construct an array `ans` of the same length such that, for each index `i`, `ans[i] | (ans[i] + 1) == nums[i]`. Minimize each `ans[i]` independently. If no non-negative value satisfies the equation, set `ans[i]` to `-1`.