public void selectCourseHour(List<List<CourseHour>> candidateList, List<CourseHour> selected, List<List<CourseHour>> results, int target) {
if (CollectionUtils.isEmpty(candidateList)){
return;
}
List<CourseHour> candidate = candidateList.get(0);
for (CourseHour oneCandidate : candidate){
if (selected.contains(oneCandidate)) continue;
List<CourseHour> currentSelected = new ArrayList<>();
currentSelected.addAll(selected);
currentSelected.add(oneCandidate);
if (currentSelected.size() >= target){
results.add(currentSelected);
}
this.selectCourseHour(candidateList.subList(1, candidateList.size()), currentSelected, results, target);
}
return;
}