class Solution {
public:
vector<string> Permutation(string str) {
if(str.length() == 0)return this->result;
int choose_table[9] = {0};
create_string(str,"",0,choose_table);
return this->result;
}
void create_string(string str, string c_str,int length,int* choose_table){
if(length == str.length()){
//相同的要删除
if(find(result.begin(),result.end(),c_str) == result.end()) result.push_back(c_str);
}
for(int i = 0;i<str.length();i++){
if(choose_table[i] != -1){
//回溯
c_str.push_back(str[i]);
choose_table[i] = -1;
create_string(str,c_str,length+1,choose_table);
choose_table[i] = 0;
c_str.pop_back();
}
}
}
private:
vector<string> result;
};