Baby Hongyoon
InterviewTime limit1sMemory limit1024 MB
Find a contiguous subarray whose bitwise OR equals K, or report that none exists.
- Level
Medium6 of 10
- Topics
- Bit manipulation, Two pointers, Array, Sliding window
- Solved
- No attempts yet
Problem
Hongyoon likes intervals. Hongyoon also likes bitwise operators. So he made a problem that combines intervals and bitwise operators.
Given an array of size , find an interval of consecutive elements whose bitwise or equals exactly . If there are several such intervals, you may choose any one of them.
Input
The first line gives and . (, )
The second line gives the array of length . ()
Output
If the interval from the -th to the -th number from the left satisfies the condition, print and separated by a space on one line. If no such interval exists, print -1 instead.