Following code can handle both unique or duplicates string!
void getPermutation(string& s, int pos, vector<string>& res){
if(pos == s.size()){
res.push_back(s);
return;
}
for (int i = pos; i<s.size(); ++i) {
if(i!=pos && s[i] == s[pos]) continue;
swap(s[i], s[pos]);
getPermutation(s, pos+1, res);
}
}
vector<string> permutation(string s){
vector<string> res;
getPermutation(s, 0, res);
return res;
}