Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with that maximum bitwise OR. Two subsets are different if they pick different indices, even when the values match. The bitwise OR of an array a is a[0] OR a[1] OR ... OR a[a.length - 1].
Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with that maximum bitwise OR. Two subsets are different if they pick different indices, even when the values match. The bitwise OR of an array a is a[0] OR a[1] OR ... OR a[a.length - 1].
Example 1:
Input: {"nums":[3,1]}
Output: 2
Constraints:
1≤nums.length≤16
1≤nums[i]≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[3,1]}
OR can only switch bits on, so the largest OR any subset reaches is the OR of all 2 numbers. First compute that target.