[C++ & 2 solutions] bit manipulation with pruning  & backtracking
\nclass CombinationIterator {\npublic:    \n    CombinationIterator(string characters, int combinationLength) {\n        this->st = GenaretallComb(characters,co
```\nclass CombinationIterator {\npublic:    \n    CombinationIterator(string characters, int combinationLength) {\n        this->st = GenaretallComb(characters,combinationLength);\n        this->cur = begin(st);\n    }\n    \n    string next() {\n        return cur==end(st)? "": *cur++;\n    }\n    \n    bool hasNext() {\n        return cur!=end(st);\n    }\n    \nprivate:\n    set<string> GenaretallComb(string s,int len){\n    int mask = 1<<s.length();\n    set<string>hold;    \n    for(int no=1;no<mask;no++){        \n        if(__builtin_popcount(no) != len) continue;\n        string comString = "";        \n        for(int num = no,i = 0; num; i++,num>>=1)\n            if(num&1) comString += s[i];            \n        //if(comString.length()==len) // this can be used in case you hate __builtin_popcount\n         hold.emplace(comString);        \n    }\n    return hold;\n}\n    \n    set<string>st;\n    set <string> :: iterator cur;\n};\n```\n\nSolution 2: Backtracking\n\n```\nclass CombinationIterator {//First, generate all the combinations of length==combinationlength\npublic:\n    vector<string> temp;\n    int i;\n    CombinationIterator(string characters, int combinationlength):i(0) {        \n        backtrack(characters,combinationlength,0,"");\n    }\n    \n    void backtrack(const string& characters,int combinationlength,int idx,string ans){        \n        for(int i=idx;i<characters.size() && ans.size()<combinationlength;i++)            \n            backtrack(characters,combinationlength,i+1,ans + characters[i]);            \n        if(ans.size()==combinationlength) temp.push_back(ans);\n    }\n    \n    string next() {return temp[i++];    }    \n    bool hasNext(){return i<temp.size();    }\n};\n```\nReference:\nhttps://leetcode.com/problems/iterator-for-combination/discuss/789164/C%2B%2B-Using-Bit-manipulation-or-Detail-Explain
['Backtracking', 'Bit Manipulation', 'Bitmask']