Homework
CodeChefOpen on judge ↗
Whenever Vinit asks Kanupriya to hang out, she's busy doing homework. Vinit wants to help her finish it faster, but he's in over his head! Can you help Vinit understand Kanupriya's homework so she can hang out with him? Consider an array of n distinct integers,A=[a0, a1,....,an] . Vineet can swap any two elements of the array any number of times. An array is beautiful if the sum of |ai - ai-1|
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