given a string array
String[] values = {"A", "B", "C", "D", "E"};
and a constant
final String X = "X";
Generate every possible way the value array can contain 0 or more X
i.e
[A, B, C, D, E]
[A, X, X, D, E]
[A, B, X, D, E]
[X, X, X, X, X]
and so on with every possibility. Needs to be fast – bit of a brain teaser i’m having trouble making efficient. Not as easy as it sounds.
Answer was in Joachim Sauer’s hint: