原文链接https://leetcode-cn.com/problems/combinations/description/
class Solution {
List<List<Integer>> res = new LinkedList<>();
public List<List<Integer>> combine(int n, int k) {
hel(n,1,k,new LinkedList<>());
return res;
}
public void hel(int n,int pos, int k,List<Integer> list) {
if(k == 0) {
List<Integer> tmp = new LinkedList<>(list);
res.add(tmp);
return;
}
for(int i = pos;i <= n-k+1;i++) {
list.add(i);
hel(n,i+1,k-1,list);
list.remove(list.size()-1);
}
}
}