Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1120,21 +1120,25 @@ private static <T> boolean cmn(List<T> all, int m, int n,
result = new ArrayList<>(n);
}

int index = result.size();
if (m == n) {
result.addAll(all.subList(current, all.size()));
n = 0;
}
if (n == 0) {
// All n items are selected
return callback.apply(result);
Boolean apply = callback.apply(result);
while (index < result.size()) {
result.remove(index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when to cause this behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can run the test:
Screenshot2023_02_28_093728
the result is:
Screenshot2023_02_28_093808

}
return apply;
}
if (current >= all.size()) {
// Reach the end of items
return false;
}

// Select current item, continue to select C(m-1, n-1)
int index = result.size();
result.add(all.get(current));
if (cmn(all, m - 1, n - 1, ++current, result, callback)) {
return true;
Expand Down