1863. Sum of All Subset XOR Totals ¶
Approach 1: DFS¶
- Time: $O(2^n)$
- Space: $O(2^n)$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 |
|
Approach 2: Math¶
- Time: $O(n)$
- Space: $O(1)$
1 2 3 4 5 6 7 |
|
1 2 3 4 5 |
|
1 2 3 |
|