how to get all the possible ways in which positions of array can be picked?
for ex for array of size 2 there are 3 possibilities first element, second element and both the elements.
for array of size 3 possibilities are first, second, third,first and second, first and third, second and third,and finally first second and third.
i want a simple nested loops for it..
how to get all the possible ways in which positions of array can be
Share
Nested loops aren’t really the answer here, because the depth of nesting would depend on the size of the array.
So you think in binary: the subsets of the size-N array correspond to the non-zero binary numbers of the right length, so do something like