I'm looking for an algorithm that given a list like:
[1, 1, 2, 1, 1, 5, 1, 1, 1, 1, 2, 1]
can find and return all subsequences of a given value. For example, if given the value 1, the function would return [[1, 1], [1, 1], [1, 1, 1, 1], [1]]
.
I believe this is similar to problems such as summing up all subsequences of an array or finding all the subsequences of a given string but algorithms was never my strong suit. The answer can be psuedo-code or language agnostic. And if you wouldn't mind, could you explain the complexity of the solution?
I can explain what I need this for if that helps. Comment if you want that.