class Solution {
public:
vector<vector<int>> permuteUnique(vector<int>& nums) {
set<vector<int>> res;
vector<int> add;
vector<int> vis(nums.size(),);
BFS(nums,res,add,vis,);
return vector<vector<int>>(res.begin(),res.end()); } void BFS(vector<int>& nums,set<vector<int>>& res,vector<int>& add,vector<int>& vis,int level){
if(level == nums.size()){res.insert(add);return;}
else{
for(int i=;i < nums.size();i++){
if(vis[i] == ){
vis[i] = ;
add.push_back(nums[i]);
BFS(nums,res,add,vis,level+);
add.pop_back();
vis[i] = ;
}
}
}
}
};
相关文章
- 10-06[leetcode] Reverse Linked List 分类: leetcode 算法 2015-07-09 18:44 2人阅读 评论(0) 收藏
- 10-06LeetCode 309. 最佳买卖股票时机含冷冻期
- 10-06LeetCode: Sum Root to Leaf Numbers [129]
- 10-06Leetcode Sum Root to Leaf Numbers
- 10-06[Leetcode] Sum root to leaf numbers求根到叶节点的数字之和
- 10-06LeetCode :: Sum Root to Leaf Numbers [tree、dfs]
- 10-06Leetcode之动态规划(DP)专题-309. 最佳买卖股票时机含冷冻期(Best Time to Buy and Sell Stock with Cooldown)
- 10-06[动态规划] leetcode 309 Best Time to Buy and Sell Stock with Cooldown
- 10-06leetcode *451. 根据字符出现频率排序(2021.7.3)
- 10-06LeetCode题解(1387):将整数按权重排序(Python)