题解 | #数组中未出现的最小正整数#
有重复项数字的所有排列
http://www.nowcoder.com/practice/a43a2b986ef34843ac4fdd9159b69863
class Solution { public: vector<int> res; vector<vector<int>> ans; vector<bool> isUsed; void backtracking(vector<int> &num){ if(res.size() == num.size()){ ans.push_back(res); return; } for(int i = 0; i < num.size();++i){ if(isUsed[i] == true || (i >= 1 && num[i] == num[i-1] && isUsed[i-1] == false))continue; isUsed[i] = true; res.push_back(num[i]); backtracking(num); res.pop_back(); isUsed[i] = false; } } vector<vector<int> > permuteUnique(vector<int> &num) { sort(num.begin(),num.end()); isUsed.resize(num.size(),false); backtracking(num); return ans; } };