Combinations
摘要:
Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]Solution:采用位运算来做,但是这样时间复杂度很高O(n* 2^ n)。 1 public class Solution { 2 public ArrayList> combine(int n, int k) { 3 /... 阅读全文
posted @ 2013-10-01 14:42 Step-BY-Step 阅读(149) 评论(0) 推荐(0) 编辑