← All problemsSign in

Balanced Positions in a Permutation

CodeChefRating 930Open on judge ↗

You are given a [permutation](https://en.wikipedia.org/wiki/Permutation) $P$ of length $N$, i.e. an array containing each integer from $1$ to $N$ exactly once. For each position $i$ ($1 \leq i \leq N$), define: - $L_i$ = the number of elements **smaller** than $P_i$ that appear to its **left**. - $R_i$ = the number of elements **greater** than $P_i$ that appear to its **right**. Your task is to

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