← All problemsSign in

Maximum Difference Sum

Ramanujan is a Mathematician. One day when he was looking for a book in library, he came across a book named Formule Di Matematica. He found it interesting and started reading it. While going through the book, he found a function D which was as following: D(1,a2,a3,..,an >) = |a1-a2| + |a2-a3| + ... +|an-1-an| where 1,a2,a3,...,an > is a sequence of n distinct integers. Ramanujan quickly unders

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start