Код: Выделить всё
class Solution {
List res = new ArrayList();
public List combine(int n, int k) {
List list = new ArrayList();
helper(k, n, list, 1);
return res;
}
private void helper(int k, int n, List list, int index){
if(list.size() == k){
res.add(new ArrayList(list));
return;
}
for(int i=index; i
Подробнее здесь: [url]https://stackoverflow.com/questions/79111799/whats-going-on-with-this-backtracking-problem[/url]