剑指offer--字符串的排列

class Solution 
{
public:
    void quanpailie(vector<string> &shuchu, string &temp, int start, int end)
    {
        if (start == end)
        {
            shuchu.push_back(temp);
        }

        for (int i = start; i <= end; ++i)
        {
            if (temp[start] == temp[i]&&i!=start)
            {
                continue;
            }
            else
            {
                swap(temp[start], temp[i]);
                quanpailie(shuchu, temp, start + 1, end);
                swap(temp[start], temp[i]);
            }
        }
    
    }

    vector<string> Permutation(string str)
    {
        int start = 0;
        int end = (str.size() - 1);
        vector<string> re;
        quanpailie(re, str, 0,end);
        sort(re.begin(), re.end());
        return re;
    }
};
原文地址:https://www.cnblogs.com/159269lzm/p/7294166.html