Tap here to switch tabs
Problem
Submissions

Problem: Shortest Subarray With OR at Least K II

med
30 min
Try to solve the Shortest Subarray With OR at Least K II problem.

Statement

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

A subarray is called special if the bitwise OR of all its elements evaluates to at least k.

Return the length of the shortest special non empty subarray of nums. If no such subarray exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤2imes105\leq 2 imes 10^5

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Subarray With OR at Least K II

med
30 min
Try to solve the Shortest Subarray With OR at Least K II problem.

Statement

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

A subarray is called special if the bitwise OR of all its elements evaluates to at least k.

Return the length of the shortest special non empty subarray of nums. If no such subarray exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤2imes105\leq 2 imes 10^5

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

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