利用好C++标准库,很好解决
字符串的排列
http://www.nowcoder.com/questionTerminal/fe6b651b66ae47d7acce78ffdd9a96c7
class Solution { public: vector<string> Permutation(string str) { if (str.empty()) return {}; sort(str.begin(), str.end()); vector<string> ans; ans.push_back(str); while (next_permutation(str.begin(), str.end())) ans.push_back(str); return ans; } };