- 先进行排序,按照字典升序的方式,给出所有排列结果。
class Solution {
public:
vector<string> Permutation(string str) {
vector<string> result;
if (str.size() == 0) return result;
sort(str.begin(), str.end());
do {
result.push_back(str);
}while (next_permutation(str.begin(), str.end()));
return result;
}
};