```class Solution {
public:
vector<vector<int> >res;
vector<int>path;
void bfs(vector<int>& num,vector<bool>& used)
{
if(path.size()==num.size())
{
res.push_back(path);
return;
}
for(int i=0;i<num.size();i++)
{
if(i>0&&num[i]==num[i-1]&&used[i-1]==true)continue;
if(used[i]==false)
{
used[i]=true;
path.push_back(num[i]);
bfs(num,used);
used[i]=false;
path.pop_back();
}
}
return;
}
vector<vector<int> > permuteUnique(vector<int> &num) {
vector<bool>used(num.size(),false);
sort(num.begin(),num.end());
bfs(num,used);
return res;
}
};