每日一题ing,今天是个medium题322. Coin Change
class Solution {
public:
vector<vector<int>> permute(vector<int>& nums) {
int len=nums.size();
vector<vector<int>> ret;
dfs(nums,ret,0,len);
return ret;
}
void dfs(vector<int>& nums,vector<vector<int>>& ret,int first,int len){
if(first==len){
ret.push_back(nums);
return;
}
for(int i=first;i<len;i++){
swap(nums[i],nums[first]);
dfs(nums,ret,first+1,len);
swap(nums[i],nums[first]);
}
}
};