leetcode 47. Permutations II
来源:互联网 发布:淘宝代发货平台 编辑:程序博客网 时间:2024/04/28 12:52
class Solution {
public:
vector<vector<int>> res;
void dfs(vector<int> nums,vector<bool>&used,vector<int>& cur)
{
if(cur.size()==nums.size())
{
res.push_back(cur);
return;
}
for(int i=0;i<=nums.size()-1;i++)
{
if(used[i]==1)
continue;
cur.push_back(nums[i]);
used[i]=1;
dfs(nums,used,cur);
cur.pop_back();
used[i]=0;
while(nums[i]==nums[i+1])
i++;
}
}
vector<vector<int>> permuteUnique(vector<int>& nums) {
int n=(int)nums.size();
sort(nums.begin(),nums.end());
vector<bool> used(n,false);
vector<int> cur;
dfs(nums,used,cur);
returnres;
}
};
- [LeetCode]47.Permutations II
- LeetCode 47.Permutations II
- LeetCode --- 47. Permutations II
- [Leetcode] 47. Permutations II
- [leetcode] 47.Permutations II
- LeetCode 47. Permutations II
- 47. Permutations II LeetCode
- Leetcode 47. Permutations II
- LeetCode 47. Permutations II
- LeetCode - 47. Permutations II
- [LeetCode] 47. Permutations II
- leetcode 47. Permutations II
- [LeetCode]--47. Permutations II
- [LeetCode]--47. Permutations II
- [leetcode] 47. Permutations II
- leetcode 47. Permutations II
- Leetcode-47. Permutations II
- [LeetCode]--47. Permutations II
- 一、Docker 知识框架以及入门基础
- kafka学习心得
- 自学机器学习入门指南
- 机器学习心得之Andrew Ng(3)
- python网络爬虫(一)
- leetcode 47. Permutations II
- 常用端口号
- 揭秘UNIX文件缓存(the buffer cache)(实战篇)
- 我的电路实验
- Java(7-2 迭代器和链表详细说明)
- idea生成类注释和方法注释的正确方法
- 隐私政策
- 集合框架
- 分类模拟