shlogg · Early preview
Md Ariful Haque @mah-shamim

Shortest Subarray With OR At Least K II

Find shortest special subarray with OR at least k using sliding window and bit manipulation techniques.

3097. Shortest Subarray With OR at Least K II
Difficulty: Medium
Topics: Array, Bit Manipulation, Sliding Window
You are given an array nums of non-negative integers and an integer k.
An array is called special if the bitwise OR of all of its elements is at least k.
Return the length of the shortest special non-empty subarray1 of nums, or return -1 if no special subarray exists.
Example 1:

Input: nums = [1,2,3], k = 2
Output: 1
Explanation: The subarray [3] has OR value of 3. Hence, we return 1.

Example 2:

Input: nums = [2,1,8], k = 10
Output: 3
Explanation: The subarray [2,1,8] has OR valu...