The XOR total of an array is the bitwise XOR of all its elements, or 0 if the array is empty. For example, the XOR total of [2,5,6] is 2 XOR 5 XOR 6 = 1.
Given an array nums, return the sum of the XOR totals of every subset of nums.
A subset is what you get by deleting some of the elements (possibly none, possibly all). Two subsets that pick different positions count separately, even if they hold the same numbers, so an array of length n has exactly 2^n subsets.
Examples
Example 1
Input: nums = [1,3]
Output: 6
The four subsets are [], [1], [3] and [1,3]. Their XOR totals are 0, 1, 3 and 1 XOR 3 = 2, and 0 + 1 + 3 + 2 = 6.
Example 2
Input: nums = [5,1,6]
Output: 28
The eight subsets have XOR totals 0, 5, 1, 6, 5 XOR 1 = 4, 5 XOR 6 = 3, 1 XOR 6 = 7 and 5 XOR 1 XOR 6 = 2. They add up to 28.
Example 3
Input: nums = [3,4,5,6,7,8]
Output: 480
There are 2^6 = 64 subsets, and their XOR totals add up to 480.
Example 4
Input: nums = [2,2]
Output: 4
The subsets are [], the first [2], the second [2] and [2,2], with XOR totals 0, 2, 2 and 0. Each 2 counts as its own subset.
Example 5
Input: nums = [7]
Output: 7
[] adds 0 and [7] adds 7.
Constraints
1 <= nums.length <= 121 <= nums[i] <= 20