Tap here to switch tabs
Problem
Submissions

Problem: Find Subarray With Bitwise OR Closest to K

med
30 min
Try to solve the Find Subarray With Bitwise OR Closest to K problem.

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

med
30 min
Try to solve the Find Subarray With Bitwise OR Closest to K problem.

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