标签:perm ring vector rac 排列组合 void turn bsp idt
题目:
解答:
1 class Solution { 2 vector<string>ans; 3 void backtracking(string &s,int start) 4 { 5 if(start==s.size()) 6 { 7 ans.emplace_back(s); 8 } 9 for(size_t i=start;i<s.size();++i) 10 { 11 swap(s[i],s[start]); 12 backtracking(s,start+1); 13 swap(s[i],s[start]); 14 } 15 } 16 public: 17 vector<string> permutation(string S) 18 { 19 backtracking(S,0); 20 return ans; 21 } 22 };
标签:perm ring vector rac 排列组合 void turn bsp idt
原文地址:https://www.cnblogs.com/ocpc/p/12861184.html