Matej Focko
94390bbf94
URL: https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets/ Signed-off-by: Matej Focko <me@mfocko.xyz>
16 lines
347 B
C#
16 lines
347 B
C#
public class Solution {
|
|
public int CountMaxOrSubsets(int[] nums) {
|
|
var dp = new int[1 << 17];
|
|
dp[0] = 1;
|
|
|
|
var max = 0;
|
|
foreach (var num in nums) {
|
|
for (int i = max; i >= 0; --i) {
|
|
dp[i | num] += dp[i];
|
|
}
|
|
max |= num;
|
|
}
|
|
|
|
return dp[max];
|
|
}
|
|
}
|