Created
April 5, 2025 10:39
-
-
Save SuryaPratapK/2172f55d0e5f188dad8aadd45810b598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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