Count how many subsets achieve the maximum possible bitwise OR.
You are given an array of non-negative integers nums. Consider every non-empty subset of nums, and compute the bitwise OR of all elements in that subset.
Your task is to return the number of subsets whose bitwise OR is as large as possible among all subsets.
A subset is formed by choosing any collection of indices from the array, and different choices of indices count as different subsets even if they contain the same values.
nums.nums.1 <= nums.length <= 160 <= nums[i] <= $10^{5}$nums: integer array of non-negative values1 <= nums.length <= 160 <= nums[i] <= $10^{5}$Example 1
Input
nums = [3, 1]
Output
2
Explanation
The maximum OR is 3. The subsets [3] and [3, 1] both have OR 3, so the answer is 2.
Example 2
Input
nums = [2, 2, 2]
Output
7
Explanation
Every non-empty subset has OR 2, which is the maximum possible OR. There are $2^{3}-1$ = 7 non-empty subsets.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.