Symmetric Swaps
Chef has two arrays $A$ and $B$ of the same size $N$. In one operation, Chef can: - Choose an index $i$ $(1 \leq i \leq N)$ and swap the elements $A_i$ and $B_i$. Chef came up with a task to find the **minimum** possible value of **($A_{max} - A_{min}$)** after performing the swap operation any (possibly zero) number of times. Since Chef is busy, can you help him solve this task? Note that $A
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