Leetcode-5087 Letter Tile Possibilities(活字印刷)
作者:互联网
1 #define _for(i,a,b) for(int i = (a);i < b;i ++) 2 3 class Solution 4 { 5 public: 6 set<string> s; 7 int numTilePossibilities(string tiles) 8 { 9 s.clear(); 10 int rnt = 0; 11 for (int S = 1; S < 1 << tiles.size(); S ++) 12 { 13 string tmp; 14 _for(i,0,tiles.size()) 15 { 16 if(S>>i & 0x1) 17 tmp += tiles[i]; 18 } 19 sort(tmp.begin(),tmp.end()); 20 do 21 { 22 if(!s.count(tmp)) 23 { 24 rnt ++; 25 s.insert(tmp); 26 } 27 }while(next_permutation(tmp.begin(),tmp.end())); 28 } 29 return rnt; 30 } 31 };
标签:tmp,begin,end,int,5087,tiles,Possibilities,Letter,rnt 来源: https://www.cnblogs.com/Asurudo/p/10993165.html