class Solution {
public:
set<string>ret;
void dfs(string str, int s) {
if (s == str.size() - 1) {
ret.insert(str);
return;
}
for (int i = s; i < str.size(); i++) {
swap(str[i], str[s]);
dfs(str, s + 1);
swap(str[i], str[s]);
}
}
vector<string> Permutation(string str) {
dfs(str, 0);
vector<string>ret1;
// 将set转为vector
set<string>::iterator it;
for (it = ret.begin(); it != ret.end(); it++) {
ret1.push_back(*it);
}
return ret1;
}
};