class Solution {
public:void rPermutation(int k, string cststr, vector<string> &rtvec) {
if (k == cststr.size() - 1)
rtvec.push_back(cststr);
for (int i = k; i < cststr.size(); i++)
{
if (i != k && cststr[k] == cststr[i])
continue;
swap(cststr[i], cststr[k]);
rPermutation(k + 1, cststr, rtvec);
}
}
vector<string> Permutation(string str) {
vector<string> rtvec;
sort(str.begin(), str.end());
rPermutation(0, str, rtvec);
return rtvec;
}
};
int main()
{
Solution mys;
vector<string> rtvec=mys.Permutation("1231");
}