# CPP

class Solution {

public:

vector\<vector\<int> > res;

vector\<int> temp;

vector\<vector\<int> > permuteUnique(vector\<int> \&num) {

sort(num.begin(), num.end());

dfs(num);

return res;

}

void dfs(vector\<int> \&num)

{

int m = num.size();

if (m == 0)

{

res.push\_back(temp);

return;

}

for (int i = 0; i < m; i++)

{

while(i\<m-1&\&num\[i]==num\[i+1]) i++;

temp.push\_back(num\[i]);

vector\<int> cur=num;

cur.erase(cur.begin()+i);

dfs(cur);

temp.pop\_back();

}

}

};
