Sum of All Subset XOR Totals Problem

Sum of All Subset XOR Totals Problem — ExecCode Easy DSA Practice

Solve the Sum of All Subset XOR Totals problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an array nums, return the sum of all XOR totals for every subset of nums. Your task is to the XOR total of an array is defined as the bitwise XOR ofall its elements, or 0 if the array isempty. For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1. Note: Subsets with the same elements should be counted multiple times. An array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b. Return the required answer exactly as shown in the examples.

Examples

Input {"nums": [1, 3]}; Output 6. Input {"nums": [5, 1, 6]}; Output 28

Constraints

1 <= nums.length <= 12 1 <= nums[i] <= 20

Practice Sum of All Subset XOR Totals free on ExecCode. Browse DSA problems, topic map, and placement guides.