2917. Find the K-th OR Value in an Array#
Given an integer array nums
and an integer k
, return the k-th
OR value of nums
.
The k-th
OR value of nums
is a non-negative integer that satisfies the following conditions:
- Only if there are at least
k
elements innums
whosei-th
bit is1
, then thei-th
bit of the OR value is1
.
Return the k-th
OR value of nums
.
Note: For an integer x
, if (2^i AND x) == 2^i
, then the i-th
bit of x
is 1
, where AND
is the bitwise AND operator.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= nums.length <= 50
0 <= nums[i] < 2^31
1 <= k <= nums.length