class Solution {
public:
    void sub(string s,int index,string path,set<string> &ans){
        //递归函数第一步:想好各个参数的含义以及如何递归
        
        if(index==s.size()){
            ans.insert(path);
        }//递归函数第二步:写base case
        else{
            string yes=path+s[index];
            sub(s,index+1,yes,ans);
            sub(s,index+1,path,ans);
        }//第三步:递归
    }
    vector<string> generatePermutation(string s) {        
        vector<string> ans;
        set<string> ans1;
        string path="";//第一步:定义初始变量
        sub(s,0,path,ans1);
        for(set<string>::iterator it=ans1.begin();it!=ans1.end();it++){
            ans.push_back(*it);
        }
        return ans;
    }
};