← All problemsSign in

Chef and Sequence

Chef loves to play with sequence. One day a friend of chef gave him a sequence of integers a1, a2, ..., an. and told him to find the maximum of strength of the sequence. Defining the strength of the sequence to be |a1 - a2| + |a2 - a3| + ... + |an-1 - an| + |an - a1|. Chef wants to make his sequence stronger, so he reorders his sequence into a new sequenceb1, b2, ..., bn. He wants this new sequenc

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