DEV Community

Karleb
Karleb

Posted on

1863. Sum of All Subset XOR Totals

https://leetcode.com/problems/sum-of-all-subset-xor-totals/?envType=daily-question&envId=2024-05-20

/**
 * @param {number[]} nums
 * @return {number}
 */
var subsetXORSum = function(nums) {
    let sum = 0

    for (let num of nums) {
        sum |= num
    }

    return sum * (1 << (nums.length - 1))
};

Enter fullscreen mode Exit fullscreen mode

Top comments (0)