No repeats please questions

No repeats please questions
0.0 0


I would like to ask few questions about the challenge:
what is n parameter in generate function, is it number of permutations, why should I check if n is even or odd and what’s purpose of tmp variable ?


Are you asking about the solution posted in the hint?

If so, the generation of permutations uses “Heap’s algorithm”, and the reason for checking if it’s even is simply a part of that algorithm.

The purpose of tmp is simply to act as a temporary place to store a value so you can swap two values.

To really get started with this problem you should first read up online about Heap’s algorithm, it should be fairly straightforward after that point