+ 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}.

25th Apr 2018, 9:03 AM
Arya Sinha
Arya Sinha - avatar
3 ответов
+ 1
What would be the subsets for {1, 1, 3}?
25th Apr 2018, 10:27 AM
Timon Paßlick
+ 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.
25th Apr 2018, 10:44 PM
Nommer101
Nommer101 - avatar
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
25th Apr 2018, 9:15 AM
Roel
Roel - avatar