Non-Primes 101
You are given an array $A$ of size $N$. Find a pair of indices $(i, j)$ such that: - $1 \le i, j \le N, i \ne j$; - $A_i + A_j$ is not prime$^{\dagger}$. In case multiple $(i, j)$ pairs are valid, you can print any one. If it is impossible to find such $(i, j)$, output $-1$ instead. $^{\dagger}$ A number $x \ (x \ge 2)$ is said to be prime if it has exactly $2$ positive divisors - $1$, and $x
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