https://www.geeksforgeeks.org/print-sums-subsets-given-set/
Given an array of integers, print sums of all subsets in it. Output sums can be printed in any order.
Examples :
Input : arr[] = {2, 3} Output: 0 2 3 5
Method 2 (Iterative)
As discussed above, there are total 2n subsets. The idea is generate loop from 0 to 2n – 1. For every number, pick all array elements which correspond to 1s in binary representation of current number.
As discussed above, there are total 2n subsets. The idea is generate loop from 0 to 2n – 1. For every number, pick all array elements which correspond to 1s in binary representation of current number.