标签:swa ++ begin else uniq ati ack vector wap
1 class Solution 2 { 3 public: 4 vector<vector<int>> permuteUnique(vector<int>& nums) 5 { 6 vector<vector<int>> res; 7 sort(nums.begin(),nums.end()); 8 helper(res,nums,0); 9 return res; 10 } 11 12 void helper(vector<vector<int>> &res,vector<int> nums,int beg) 13 { 14 int sz=nums.size(); 15 if(beg==sz-1) 16 { 17 res.push_back(nums); 18 return ; 19 } 20 else 21 { 22 for(int i=beg;i<sz;i++) 23 { 24 if(i!=beg&&nums[i]==nums[beg]) 25 continue; 26 else 27 { 28 swap(nums[i],nums[beg]); 29 helper(res,nums,beg+1); 30 } 31 32 } 33 } 34 } 35 };
这里有个问题,为啥不用nums的引用
标签:swa ++ begin else uniq ati ack vector wap
原文地址:https://www.cnblogs.com/zhuangbijingdeboke/p/9290944.html