Find valid assignments of integers in arrays (permutations with given order)

前端 未结 5 1424
醉梦人生
醉梦人生 2021-01-06 06:33

I am having a general problem finding a good algorithm for generating each possible assignment for some integers in different arrays.

Lets say I have n arrays and m

5条回答
  •  盖世英雄少女心
    2021-01-06 07:35

    This smells like recursion. First calculate the combinations for putting m-1 in n arrays. Then you get n more solutions by putting the first number in either of the n arrays in those solutions.

提交回复
热议问题