Generate all subsequence combinations

I need all combinations of subsets of a string. In addition, a subset of length 1 can only be followed by a subset with length > 1. E.g. for string 4824 the result should be:

[ [4, 824], [4, 82, 4], [48, 24], [482, 4], [4824] ]

I have the python code to this solution so far:
1
2
3
4
5
6
7
def getSubSequences(self, s, minLength=1):
    if len(s) >= minLength:
    for i in range(minLength, len(s) + 1):
        for p in self.getSubSequences(s[i:], 1 if i > 1 else 2):
            yield [s[:i]] + p
    elif not s:
    yield []

But have some serious trouble to rewrite the 'yield' in C++.
Does anyone know how to do this?
Last edited on
Topic archived. No new replies allowed.