Good Arrangement
An array $B = [B_1,B_2,B_3,\ldots ,B_N]$ is called a *good* array if the following condition holds for every $1 \leq i \leq N$: - $B_i$ is either the maximum or the minimum element in the subarray $[B_1,B_2,\ldots,B_i]$. You are given an array $A$ containing $N$ integers. Find the number of its distinct rearrangements that are *good*. Two rearrangements $B$ and $C$ are considered different if th
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.
Sign in to chat with the tutor and save your progress.
Sign in to start