Make that Array!
Chef is given two arrays $A$ and $B$, each having $N$ elements. In one move, Chef can choose an index $i$ $(1 \leq i \leq N-1$), get $(A_i - A_{i+1})$ points, and then swap $A_i$ and $A_{i+1}$. **For example:** If Chef has the array - $[10, 7,5]$ and Chef chooses index $1$ during his move, he will get $10 - 7 = 3$ points and the new array will become $[7 , 10 ,5]$ Can you help Chef in finding t
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