Not Prime Permutation
You are given a permutation $P$ of the integers $\{1, 2, 3, \ldots N\}$. Find **any** permutation $A$ of $\{1, 2, \ldots, N\}$ such that, for *every* index $i$ ($1 \leq i \leq N$), $A_i + P_i$ is **not** a [prime number](https://en.wikipedia.org/wiki/Prime_number). If no such permutation $A$ exists, print $-1$ instead. **Note:** A permutation of $\{1, 2, \ldots, N\}$ is an array of length
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