← All problemsSign in

World of Permutations

Consider the following algorithm, which generates a (not necessarily uniformly) random permutation of numbers **1** through **N**: P := [1, 2, ..., $N$] for i in 1..$N$ do j := rand(1, $N$) swap($P$[$i$], $P$[$j$]) Here, rand(1, **N**) returns a uniformly random integer between 1 and **N** inclusive. Let's denote the probability of the permutation **P** generated by this algorithm by **p**($P

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start