#3171
Find Subarray With Bitwise OR Closest to K
international master · 1955 · lc hard +32 · 30.9% accepted · 205 likes · top 8%
Description
Given an array nums and integer k, find a non-empty contiguous subarray whose bitwise OR is as close to k as possible. Return the minimum possible value of |k - OR(subarray)|.
Code
1
2
3