Java - Recursion [Explained]
Use precomputation to generate permutation, return the permutation in order when queried through next() method.\n2. Approach: Iterate through chars in the given
1. Use precomputation to generate permutation, return the permutation in order when queried through next() method.\n2. Approach: Iterate through chars in the given \'characters\' string. At each index either\n\ti)  Include the char at that index in current string and move forward.\n\tii) Skip the char at that index and move forward.\n\n```\nclass CombinationIterator {\n    List<String> list;\n    int index = 0;\n    public CombinationIterator(String characters, int combinationLength) {\n        list = new ArrayList<>();\n        generateSeq(characters,"", 0, 0, combinationLength);\n        Collections.sort(list);\n    }\n    void generateSeq(String characters, String current, int iterIndex, int count, int cLen) {\n        if(count == cLen) {\n            String newStr = new String(current);\n            list.add(newStr);\n            return;\n        }\n        if(iterIndex == characters.length()) {\n            return;\n        }\n        generateSeq(characters, current + characters.charAt(iterIndex), iterIndex + 1, count + 1, cLen);\n        generateSeq(characters, current, iterIndex + 1, count, cLen);\n    }\n\n    public String next() {\n        String res = list.get(index);\n        index++;\n        return res;\n    }\n    \n    public boolean hasNext() {\n        if(index == list.size()) {\n            return false;\n        }\n        return true;\n    }\n}\n```
['Java']