# 77. Combinations

/*
c(n,k)=c(n-1,k-1)+c(n-1,k)
*/
class Solution {
public:
vector<vector<int>> combine(int n, int k) {

vector<vector<int>> result;
if(k==n||k==0)
{

vector<int> temp;
for(int i=1;i<=k;i++)
{
temp.push_back(i);
}
result.push_back(temp);
return result;
}
else
{
vector<vector<int>> result2=combine(n-1,k);
vector<vector<int>> result1=combine(n-1,k-1);
for(int i=0;i<result1.size();i++)
{
result1[i].push_back(n);
result2.push_back(result1[i]);
}

return result2;
}

}
};

#### LeetCode77——Combinations

2015-11-17 21:21:10

#### 77 Combinations

2015-10-25 16:20:02

#### <LeetCode OJ> 77. Combinations

2016-03-09 15:35:14

#### leetcode 77. Combinations-排列|递归|非递归|Java|Python

2016-06-02 10:43:01

#### 【leetcode】【77】Combinations

2015-11-26 14:45:38

#### LeetCode-77 Combinations(组合)

2015-05-02 12:06:29

#### leetCode 77.Combinations (组合)

2015-07-22 13:15:00

#### [LeetCode 77] Combinations

2015-03-29 14:11:58

#### [LeetCode]77.Combinations

2015-02-06 16:44:59

#### [LeetCode 77] Combinations(精妙的迭代）

2017-02-08 23:25:16