 <p>A recursive solution is probably a good solution. The function would only find the permutations of the first two arrays and then once combined into a single array, you would call this function again with the new combined array instead of the original arrays.</p> <p>Eventually you would only have 1 array left and that would be the final result array.</p>