I have the following 2D array:
String[M][]
String[0]
\"1\",\"2\",\"3\"
String[1]
\"A\", \"B\"
.
.
.
String[M-1]
\"!\"
A
Should be straight forward to do with recursion.
Let me rephrase a bit, so the terminology is less confusing.
We will call String[] as Token List, which is a list of Tokens
Now you have a List of Token List, you want to get one Token from each Token List available, and find out all combination.
What you need to do is, given a list of TokenList
I am only giving a psuedo code:
List allCombinations(List listOfTokenList) {
if (length of strings == 1) {
return strings[0];
}
List subListCombinations
= allCombination(listOfTokenList.subList(1)); // sublist from index 1 to the end
List result;
for each (token in listOfTokenList[0]) {
for each (s in subListCombination) {
result.add(token + s);
}
}
return result;
}