(JAVA) Generate Combinations
Brute force solution. Generate all subsequences and add to a priority queue\n\n\nPriorityQueue<String> pq = new PriorityQueue<>();\n    public CombinationIterat
Brute force solution. Generate all subsequences and add to a priority queue\n\n```\nPriorityQueue<String> pq = new PriorityQueue<>();\n    public CombinationIterator(String s, int k) {\n        generateSub(s,k,0,new StringBuilder());\n    }\n    private void generateSub(String s ,int len,int start,StringBuilder result) {\n        if (len == 0){\n            pq.add(result.toString());\n            return;\n        }\n        for (int i = start; i <= s.length()-len; i++){\n            result.append(s.charAt(i));\n            generateSub(s, len-1, i+1, result);\n            result.deleteCharAt(result.length()-1);\n        }\n    }\n    public String next() {\n        return pq.poll();\n    }\n    public boolean hasNext() {\n        return !pq.isEmpty();\n    }\n```
[]