Tap here to switch tabs
Problem
Submissions

Problem: Find Subarray With Bitwise OR Closest to K

Find Subarray With Bitwise OR Closest to K asks you to examine an integer array and find the smallest absolute difference between K and the bitwise OR of any contiguous subarray.

Statement

You are given an array of integers nums and an integer k.

Your task is to find the minimum possible absolute difference between k and the bitwise OR of all elements in any contiguous subarray of nums.

Return this minimum absolute difference.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Subarray With Bitwise OR Closest to K

Find Subarray With Bitwise OR Closest to K asks you to examine an integer array and find the smallest absolute difference between K and the bitwise OR of any contiguous subarray.

Statement

You are given an array of integers nums and an integer k.

Your task is to find the minimum possible absolute difference between k and the bitwise OR of all elements in any contiguous subarray of nums.

Return this minimum absolute difference.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤109\leq 10^9