generating Variations without repetitions / Permutations in java

后端 未结 10 1107
半阙折子戏
半阙折子戏 2021-01-02 07:33

I have to generate all variations without repetitions made of digits 0 - 9.

Length of them could be from 1 to 10. I really don\'t know how to solve it, especially ho

10条回答
  •  误落风尘
    2021-01-02 08:10

    Brief helpful permutation indexing Knowledge

    Create a method that generates the correct permutation, given an index value between {0 and N! -1} for "zero indexed" or {1 and N!} for "one indexed".

    Create a second method containing a "for loop" where the lower bound is 1 and the upper bound is N!. eg.. "for (i; i <= N!; i++)" for every instance of the loop call the first method, passing i as the argument.

提交回复
热议问题