Construct an array of the same length where each position is chosen to make the resulting bitwise property as small as possible under the problem's rule.
Given an integer array nums, construct a new array ans of the same length by choosing a value for each position according to the bitwise rule implied by the problem. The goal is to make each chosen value as small as possible while still satisfying the required condition.
This is a constructive bitwise problem: inspect each number independently, apply the smallest valid transformation, and return the resulting array.
nums.ans of the same length.ans[i] should be the minimum valid value for position i under the given bitwise condition.1 <= nums.lengthExample 1
Input
nums = [2, 3, 5]
Output
[1, 1, 4]
Explanation
Illustrative example: each value is transformed independently into the smallest number that satisfies the required bitwise rule.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.