class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param s string字符串
* @return string字符串vector
*/
void dfs(int u, string path, string s, unordered_set<string>& S) {
if(u == s.size()) {
S.insert(path);
return ;
}
path += s[u];
dfs(u + 1, path, s, S);
path.pop_back();
dfs(u + 1, path, s, S);
}
vector<string> generatePermutation(string s) {
// write code here
unordered_set<string> S;
dfs(0,"",s, S);
return vector<string>(S.begin(), S.end());
}
};

京公网安备 11010502036488号