Skip to content

Practice Shortest Subarray With OR at Least K I

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3095
LeetCode Problem

Shortest Subarray With OR at Least K I

Problem Statement

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 subarray of nums, or return -1 if no special subarray exists.

Source: Shortest Subarray With OR at Least K I on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3], k = 2
Output
1

# Example 2

Input
nums = [2,1,8], k = 10
Output
3

# Example 3

Input
nums = [1,2], k = 0
Output
1

Constraints

1 <= nums.length <= 50
0 <= nums[i] <= 50
0 <= k < 64

Related LeetCode Problems

Practice more problems similar to Shortest Subarray With OR at Least K I.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.