Compute the sum of XOR values over every subset of an array.
Given an integer array nums, consider every possible subset of nums, including the empty subset.
For each subset, compute the bitwise XOR of all its elements. Return the sum of these XOR values across all subsets.
A subset is any selection of elements from the array, preserving no particular order. Different positions in the array are treated as distinct elements.
0.nums.nums.0 <= nums.length <= 200 <= nums[i] <= $10^{9}$Example 1
Input
nums = [1,3]
Output
6
Explanation
Subsets are [], [1], [3], [1,3].
Their XOR totals are 0, 1, 3, 2.
Sum = 0 + 1 + 3 + 2 = 6.
Example 2
Input
nums = [5,1,6]
Output
28
Explanation
There are 8 subsets in total. The XOR totals are 0, 5, 1, 6, 4, 3, 7, 2, and their sum is 28.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.