← All problemsSign in

Messi and his Permutation

Messi is a brilliant student. Once his teacher Koeman provided him with a permutation of length $N$ to take care of. Mistakenly Messi shuffled it. He knows when Koeman gets to know about this he will become upset. There is one special property about permutation that the sum of all the prefix minimums is exactly $Y$ i.e., let $A[i] = min(Arr[1], Arr[2], ..., Arr[i])$, then $\sum_{i=1}^{N} A[i]$ = $

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