Generate all unique combinations of Items
问题 I trying to generate all possible unique combination of items. Ex: item1, item2, item3 Combinations: item1+item2+item3 item1+item2 item1+item3 item2+item3 item1 item2 item3 I am unable to get an idea on how to solve this? for(int i=0;i<size;i++){ for(int j=i+1;j<size;j++){ System.out.println(list.item(i)+list.item(j)); } } The above code certainly works for all unique combination of two elements. But not for 3 element pair and more.. 回答1: If you have N items, count from 1 to 2^N-1. Each