[C++] Explained Solution || Backtracking || 10 ms || Combination
The easiest way I could think of is, first you store all possible strings of size \'l\' in a new vector ( vector< string > v; ) and set an iterator with value 0
The easiest way I could think of is, first you store all possible strings of size \'l\' in a new vector ( vector< string > v; ) and set an iterator with value 0 ( index=0 ) and whenever next function called you just need to return v[index] and increase index by 1 and when hasNext function got called, you just need to check if the index is less than the size of vector v or not.\n.\nNow to get the vector of all combination we need to go through backtracking.\n\n**There is a question on same process on leetcode (77. Combinations) {https://leetcode.com/problems/combinations/}**\n\nPlease go through the mentioned question first then this one will be so easy task to do.\n\n```\nclass CombinationIterator {\npublic:\n    vector<string>v;\n    int index=0;\n    void comb(string&st,string c,int l,int s){\n        if(c.size()==l) {\n            v.push_back(c);\n            return;\n        }\n        for(int i=s;i<st.size();i++) {\n            c.push_back(st[i]);\n            comb(st,c,l,i+1);\n            c.pop_back();\n        }\n    }\n    CombinationIterator(string ch, int l) {\n        comb(ch,"",l,0);\n    }\n    \n    string next() {\n        return v[index++];\n    }\n    \n    bool hasNext() {\n        return index<v.size();\n    }\n};\n```\nHope it was helpful ;)\n
['Backtracking', 'C']