I have n number of one-dimensional arrays similar to:
0's and 1's indicating occupation.
And k number of smaller arrays similar to:
[2,2,2], [2,2], , [2,2,2,2]
with varying sizes. What I want to do is to see where and how I can fit the smaller (second) arrays to bigger arrays following each other buy indexes. Example:
Domain Arrays:     Smaller Arrays:    Result:    
   
I hope I could put it into words well.
My solution is:
Finding empty spots that can fit any of the smaller arrays. And creating a tree with possible combinations like;
1-First small array goes to second big arrays 3rd index and occupies 3 spaces 2-Second small array goes to first big arrays 7th index and occupies 4 spaces
and I get the patterns of every branch on the tree with depth of smaller array count. But it of course works slowly. Which algorithms can I use to solve this problem? Thank you in advance.