The probability that one particular permutation will show up is 1/n!. So for smaller cases, generating all the permutations either recursively will do. It is also possible to use standard libraries to generate the permutations as well. But for case where the array size is 11, it is not possible to solve the problem within given runtime. One solution would be to pre-generate all the answers up to 11 and print them.

Some contest time solutions also used this clever idea.

Statistics

78% Solution Ratio
BrehamPieEarliest, Feb '21
BrehamPieFastest, 0.0s
BrehamPieLightest, 0 B
CPSCR_PiratesShortest, 93B
Toph uses cookies. By continuing you agree to our Cookie Policy.