题解 | #字符串的排列#
字符串的排列
http://www.nowcoder.com/practice/fe6b651b66ae47d7acce78ffdd9a96c7
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; } };