这个helper函数代码少了几行。。我加在这里,我觉得思路很清晰,怎么编译不过呢
private static List<List<Integer[]>> helper(List<Integer[]> bookSet, int num) {
List<List<Integer[]>> ret = new ArrayList<>();
List<Integer[]> bookSetCombination=new ArrayList<>();
if(num>bookSet.size()) return ret ;
if(num==1) {
for (Integer[] book : bookSet)
{
bookSetCombination.add(book.clone());
ret.add(bookSetCombination);
}
return ret;
}
if (num == bookSet.size()) {
for (Integer[] book : bookSet)
{
bookSetCombination.add(book.clone());
}
ret.add(bookSetCombination);
return ret;
}
if (num < bookSet.size()) {
for (int i=0;i<bookSet.size();i++)
{
bookSetCombination.add(bookSet.get(i).clone());
List<Integer[]> tmpBookSet = new ArrayList<>(bookSet);
for(Integer[] tmpBook : tmpBookSet) {
if(tmpBook.equals(bookSet.get(i))) {
tmpBookSet.remove(tmpBook);
}
}
ret=helper(tmpBookSet, num-1);
for(List<Integer[]> combination :ret) {
bookSetCombination.addAll(combination);
ret.add(bookSetCombination);
}
}
}
return ret;
}
【 在 iStudy 的大作中提到: 】
: 大神,能帮我看这修改一下吗?
: package test;
: import java.util.ArrayList;
: ...................
--
修改:iStudy FROM 58.37.127.*
FROM 58.37.127.*