1286. Iterator for Combination | C++ | Generate all combinations | Recursion
Below is my code:\n\n\nclass CombinationIterator {\npublic:\n    \n    vector<string> arr;\n    int index=0;\n    \n    void helper(string s,int count,int len,s
Below is my code:\n\n```\nclass CombinationIterator {\npublic:\n    \n    vector<string> arr;\n    int index=0;\n    \n    void helper(string s,int count,int len,string temp){\n        if(s.size()==0){\n            if(count==len)\n                arr.push_back(temp);\n            return;\n        }\n        helper(s.substr(1),count+1,len,temp+s[0]);\n        helper(s.substr(1),count,len,temp);\n    }\n    \n    CombinationIterator(string s, int len) {\n        int n=s.size();\n        string temp="";\n        helper(s,0,len,temp);\n        sort(arr.begin(),arr.end());\n        for(int i=0;i<arr.size();i++){\n            cout<<arr[i]<<" ";\n        }\n    }\n    \n    string next() {\n        if(index>=arr.size()){\n            return "";\n        }\n        string ans=arr[index];\n        index++;\n        return ans;\n    }\n    \n    bool hasNext() {\n        return index<arr.size();\n    }\n};\n```
['Recursion', 'C']