+ 1

how to get subsets of specific number from a given set of numbers?

there can be n number of subset from set, also where to save that subset.

1st May 2017, 9:18 AM
Shaikh Nooralam
Shaikh Nooralam - avatar
5 Respostas
+ 2
create an empty collection. Iterate over the numbers, make a condftion for the specific number(s) and in the if add the current number to the created collection. Example: Lets numbers contains {1,2,3,4,5,6} List<Integer> evenNumbers = new ArrayList<>(); for(Integer i : numbers){ if(i % 2 == 0){ evenNumbers.add(i); } } Then evenNumberscontains {2,4,6} It works for Set too instead List.
1st May 2017, 9:25 AM
Szabó Gábor
Szabó Gábor - avatar
+ 3
Hi ! You must create a powerSet first, then you can get the subset from that. I made a code for this: https://code.sololearn.com/cmq25jsL18bT/#java
1st May 2017, 12:32 PM
Szabó Gábor
Szabó Gábor - avatar
+ 3
Did you check the code ?
5th May 2017, 5:12 PM
Szabó Gábor
Szabó Gábor - avatar
0
thats solution for different question
1st May 2017, 9:21 AM
Shaikh Nooralam
Shaikh Nooralam - avatar
0
i want subsets, of specific length, that's possible in that set
1st May 2017, 9:27 AM
Shaikh Nooralam
Shaikh Nooralam - avatar