Forgotten Permutation
Chef has a permutation$^{\dagger}$ $P$of $N$ integers. Consider an array $S$ of $M$ integers. For each $i$ $(1 \leq i \leq M)$, $S_i$ is defined as $$ S_i = P_i + P_{i\%M+1} $$ Chef forgot the original permutation $P$ and only remembers array $S$. Help Chef by providing the number of all possible permutation $P$ of size $N$ which gives same array $S$. Formally, given an array $S$ of $M$ posit
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.
Sign in to chat with the tutor and save your progress.
Sign in to start