Loading...
You are given two integer arrays of the same length, nums and scores, and an integer limit.
Choose a subset of indices (possibly empty) such that the bitwise OR of the chosen nums values is at most limit:
nums[i1] | nums[i2] | ... | nums[im] <= limit
The bitwise OR of the empty subset is 0.
Return the maximum possible sum of the corresponding scores values.
Input: nums = [1, 2, 4, 8], scores = [5, 3, 2, 6], limit = 9
Output: 11
Explanation: Choosing indices 0 and 3 gives OR = 1 | 8 = 9 <= 9 and score 5 + 6 = 11.
Choosing indices 0, 1, 2 gives OR = 7 <= 9 but only scores 10. No subset beats 11.
Input: nums = [7], scores = [10], limit = 3
Output: 0
Explanation: 7 > 3, so the only valid subset is the empty one with score 0.
nums.length = scores.lengthnums[i], limit <230scores[i] ≤104Click "Run" to test with sample cases or "Submit" to run all tests.