标签:http ble 重复 链接 == code 复数 size 重复数
给定一个可包含重复数字的序列,返回所有不重复的全排列。
示例:
输入: [1,1,2]
输出:
[
[1,1,2],
[1,2,1],
[2,1,1]
]
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/permutations-ii
class Solution { public: vector<vector<int>>s; int n; void f(vector<int>& a,int x){ if(x==n)s.push_back(a); else{ for(int i=x;i<n;i++){ int o=0; for(int j=x;j<i;j++){ if(a[i]==a[j]){ o=1; break; } } if(o==0){ swap(a[x],a[i]); f(a,x+1); swap(a[x],a[i]); } } } } vector<vector<int>> permuteUnique(vector<int>& nums) { n=nums.size(); f(nums,0); return s; } };
标签:http ble 重复 链接 == code 复数 size 重复数
原文地址:https://www.cnblogs.com/wz-archer/p/12589935.html