Count Number of Maximum Bitwise-OR Subsets LeetCode solution in JavaScript
1/**2* @param {number[]} nums3* @return {number}4*/5var countMaxOrSubsets = function (nums) {6let n = nums.length;7let len = Math.pow(2, n);8let ans = 0;9let hash = {};1011for (let i = 0; i < len; i++) {12let tmp = 0;13for (let j = 0; j < n; j++) {14if (i & (1 << j)) {15tmp |= nums[j];16}17}18if (hash[tmp]) {19hash[tmp] += 1;20} else {21hash[tmp] = 1;22}23ans = Math.max(ans, tmp);24}2526return hash[ans];27};