3022. Minimize OR of Remaining Elements Using Operations
You are given a 0-indexed integer array
nums
and an integerk
.In one operation, you can pick any index
i
ofnums
such that0 <= i < nums.length - 1
and replacenums[i]
andnums[i + 1]
with a single occurrence ofnums[i] & nums[i + 1]
, where&
represents the bitwiseAND
operator.Return the minimum possible value of the bitwise
OR
of the remaining elements ofnums
after applying at mostk
operations.
c++
1 |
|