Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SuryaPratapK/2172f55d0e5f188dad8aadd45810b598 to your computer and use it in GitHub Desktop.
Save SuryaPratapK/2172f55d0e5f188dad8aadd45810b598 to your computer and use it in GitHub Desktop.
class Solution {
public:
int subsetXORSum(vector<int>& nums) {
int n = nums.size();
int orr = 0;
for(int ele: nums)
orr |= ele;
return orr * (1<<(n-1));
}
};
/*
//JAVA
import java.util.List;
class Solution {
public int subsetXORSum(int[] nums) {
int n = nums.length;
int orr = 0;
for (int ele : nums) {
orr |= ele;
}
return orr * (1 << (n - 1));
}
}
#Python
from typing import List
class Solution:
def subsetXORSum(self, nums: List[int]) -> int:
n = len(nums)
orr = 0
for ele in nums:
orr |= ele
return orr * (1 << (n - 1))
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment