I have three arrays:
{}
{a, b, c}
{d, e}
I am trying to combine them to get the following arrays:
{a, d}
{a, e}
{b, d}
{b, e}
{c, d}
{c, e}
The problem I am coming across is the first empty array causes a nested for loop to not run at all - logically makes sense. ie:
for (int i = 0; i < bL.size(); i++) {
for (int j = 0; j < dL.size(); j++) {
for (int k = 0; k < oL.size(); k++) {
What I am trying to find is the most efficient way to combine the three arrays regardless of their size. Most of the time all three have elements, but there are cases where one might generate an empty set.
Any help appreciated.
EDIT: Adding output for all three arrays
Input - {a,b} {c,d} {e,f}
Output - {a,c,e} {a,c,f} {a,d,e} {a,d,f} {b,c,e} {b,c,f}
EDIT: It's only possible for the first or third array to result in an empty set