Permutation Creation
JJ gives you a number $N$ and challenges you to construct a permutation $P$ of length $N$ such that: - $|P_{i + 1} - P_i| \ge 2$ for all $1 \le i \le N - 1$ (Here $|x|$ denotes the absolute value of $x$) Can you complete JJ's challenge? As a reminder, a permutation of length $N$ is an array where every integer from $1$ to $N$ occurs exactly once. ### Input - The first line contains a single int
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