⭐️  [ Javascript / Python3 / C++ ] 🚀  Recursive DFS + BT
Synopsis:\n\nPrecompute all combinations via DFS + BT to explore all paths \u2705  with A[i] and \uD83D\uDEAB  without A[i]\n\n---\n\nJavascript\n\nclass Combin
**Synopsis:**\n\nPrecompute all combinations via DFS + BT to explore all paths `\u2705  with A[i]` and `\uD83D\uDEAB  without A[i]`\n\n---\n\n*Javascript*\n```\nclass CombinationIterator {\n    constructor(A, K) {\n        this.A = A;\n        this.K = K;\n        this.i = 0;\n        this.combos = [];\n        this.go();\n    }\n    go(i = 0, path = [], A = this.A, K = this.K) {\n        if (path.length == K) {\n            this.combos.push([...path]);\n            return;\n        }\n        if (i == A.length)\n            return;\n        this.go(i + 1, path.concat(A[i])); // \u2705 with    A[i]\n        this.go(i + 1, path);              // \uD83D\uDEAB without A[i]\n    }\n    next() {\n        return this.combos[this.i++].join(\'\');\n    }\n    hasNext() {\n        return this.i < this.combos.length;\n    }\n}\n```\n\n*Python3*\n```\nclass CombinationIterator:\n    def __init__(self, A: str, K: int):\n        self.A = A\n        self.K = K\n        self.i = 0\n        self.combos = []\n        self.go()\n\n    def go(self, i = 0, path = []) -> None:\n        A, K = self.A, self.K\n        if len(path) == K:\n            self.combos.append(path.copy())\n            return\n        if i == len(A):\n            return\n        self.go(i + 1, path + [A[i]])  # \u2705 with    A[i]\n        self.go(i + 1, path)           # \uD83D\uDEAB without A[i]\n\n    def next(self) -> str:\n        res = self.combos[self.i]\n        self.i += 1\n        return \'\'.join(res)\n\n    def hasNext(self) -> bool:\n        return self.i < len(self.combos)\n```\n\n*C++*\n```\nclass CombinationIterator {\n    string A;\n    int K, i;\n    vector<string> combos;\n    void go(int i = 0, string&& path = {}) {\n        if (path.size() == K) {\n            combos.push_back(path);\n            return;\n        }\n        if (i == A.size())\n            return;\n        go(i + 1, path + A[i]);  // \u2705 with    A[i]\n        go(i + 1, move(path));   // \uD83D\uDEAB without A[i]\n    }\npublic:\n    CombinationIterator(string A, int K) : A{ A }, K{ K }, i{ 0 } {\n        go();\n    }\n    string next() {\n        return combos[i++];\n    }\n    bool hasNext() {\n        return i < combos.size();\n    }\n};\n```
[]