next_permutation真香
class Solution {
public:
int a[15];
vector<string> Permutation(string str) {
vector<string>res;
memset(a,0,sizeof a);
int n=str.size();
for(int i=0;i<n;i++){
a[i]=str[i]-'a';
}
do{
string t;
for(int i=0;i<n;i++)
t+=a[i]+'a';
res.emplace_back(t);
}while(next_permutation(a,a+n));
return res;
}
}; 
京公网安备 11010502036488号