← All problemsSign in

SUM OVER PERMUTATIONS

Chef has an array $A$ which is a permutation of natural numbers till $n$. He defines value of an array as no of elements in the array whose neighboring elements have sum at least $k$.(Note that first and last element of an array have only 1 neighboring elements where as remaining elements have 2 neighboring elements each.) You don't know the permutation that chef has, so you decide to find the su

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