+ 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.
5 Antworten
+ 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.
+ 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
+ 3
Did you check the code ?
0
thats solution for different question
0
i want subsets, of specific length, that's possible in that set