Sum of XOR sum of all subsets of an array.

Revision en1, by demons_paw, 2023-02-15 09:57:03

Given an array of size $$$n$$$. How can we find sum of XOR sum of all subsets in better than $$$O(2^n)$$$ ?
For example consider $$$array = [1,4,5]$$$
$$$ Answer = 1 + 4 + 5 + 1^4 + 1^5 + 4^5 + 1^4^5 $$$ (here '^' denotes bitwise XOR )

Basically harder version of this leetcode problem, with nums.length <= 10^5.

Tags xor, subset, easy

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English demons_paw 2023-02-15 09:57:03 426 Initial revision (published)