class Solution {
public:
int minimumDifference(vector<int>& nums, int k) {
int ans = 1e9 + 7,n = nums.size();
for(int i = 0;i < n;i++){
ans = min(ans,abs(k - nums[i]));
for(int j = i - 1;j >= 0;j--){
if((nums[j] & nums[i]) == nums[j])break;
nums[j] &= nums[i];
ans = min(ans,abs(k - nums[j]));
}
}
return ans;
}
};
12-23
996
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)