423,688 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,688 IT Pros & Developers. It's quick & easy.

arrayList Method

P: 4
A method that creates a total of "n: elements (all different if yes), their combinations of 1-2-3 .... n without repetition
Example:
Entry:
N = {a, b, c}
Comb.1: a | b | c
Comb.2: ab | bc | ac
Comb.3: abc

this I did so far please help!


String combine(ArrayList<Integer> a, String b){
String c="";
if(b.length()==a.size()){
System.out.println(b); //found a combo
return "";
}
//append characters to string b
for(int x=0;x<a.size();x++){
c=b+((Integer)a.get(x)).intValue();
c+=combine(a,c);
}
return c;
}
2 Weeks Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.