What is the efficient algorithm to find all the combinations of inserting an array A into another array B, while maintaining the order of these two arrays? (Both array A and B are the same size)
For example:
Array A = {1,2,3,4}
Array B = {5,6,7,8}
Merged array 1 = {5,1,2,3,4,6,7,8}
Merged array 2 = {5,1,6,2,3,7,4,8}
...and so on for many more combinations...
Merged array n = {1,5,6,2,3,7,4,8}