标签:style blog http color java os io for
题目:
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:
[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]
题解:
这道题就是用DFS(参考Work BreakII)的循环递归处理子问题的方法解决。n为循环的次数,k为每次尝试的不同数字。用到了回溯。
代码如下:
Reference:http://blog.csdn.net/linhuanmars/article/details/21260217
Combinations leetcode java,布布扣,bubuko.com
标签:style blog http color java os io for
原文地址:http://www.cnblogs.com/springfor/p/3877168.html