#3097

Shortest Subarray With OR at Least K II

medium · 50.2% accepted · 758 likes · top 38%

array · bit manipulation · sliding window

⊣ practice⊣ open on leetcode ↗

Description

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.

Solution