Class Solution
-
- All Implemented Interfaces:
public final class Solution3097 - Shortest Subarray With OR at Least K II.
Medium
You are given an array
numsof non-negative integers and an integerk.An array is called special if the bitwise
ORof all of its elements is at leastk.Return the length of the shortest special non-empty subarray of
nums, or return-1if no special subarray exists.Example 1:
Input: nums = 1,2,3, k = 2
Output: 1
Explanation:
The subarray
[3]hasORvalue of3. Hence, we return1.Example 2:
Input: nums = 2,1,8, k = 10
Output: 3
Explanation:
The subarray
[2,1,8]hasORvalue of11. Hence, we return3.Example 3:
Input: nums = 1,2, k = 0
Output: 1
Explanation:
The subarray
[1]hasORvalue of1. Hence, we return1.Constraints:
<code>1 <= nums.length <= 2 * 10<sup>5</sup></code>
<code>0 <= numsi<= 10<sup>9</sup></code>
<code>0 <= k <= 10<sup>9</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegerminimumSubarrayLength(IntArray nums, Integer k)-
-
Method Detail
-
minimumSubarrayLength
final Integer minimumSubarrayLength(IntArray nums, Integer k)
-
-
-
-