+ 1
How to obtain subsets of any given array with minimum time complexity and greater simplicity .
suppose A={1,2,3} how to obtain subsets {1}, {2},{3}, {1,2}, {2,3}, {1,3}, {1,2,3}.
3 odpowiedzi
+ 1
What would be the subsets for {1, 1, 3}?
+ 1
function SubSet (array, startIndex, endIndex){
var subset =[];
for (;startIndex < endIndex; startIndex++){
subset.push (array [startIndex]);
}
return subset;
}
won't work for non adjacent sets such as 1, 3 but you can modify code to warp around index if you like.
0
i think (idk what language) it works like this
a=[1,2,3];
action with a(0) (to get 1)
action with a(0, 1) (to get 1,2)
im not sure i used the correct brackets