class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param s string字符串
* @return string字符串vector
*/
vector<string> res;
char tmp[11];
int n;
int vis[11]={0};
//dfs 的全排列模板
void dfs(int x, string s) {
if (x == n) {
string str="";
for(int i=0;i<n;i++)
{
str+=tmp[i];
}
res.push_back(str);
return;
}
for (int i = 0; i < n; i++) {
if (!vis[i]) {
vis[i] = 1;
tmp[x] = s[i];
dfs(x + 1, s);
vis[i] = 0;
}
}
}
vector<string> cowPermutations(string s) {
// write code here
n = s.size();
//冒泡排序 保持字典序
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (s[i] > s[j]) {
char str = s[i];
s[i] = s[j];
s[j] = str;
}
}
}
dfs(0, s);
return res;
}
};