Count the Permutations (always)
You are given an array $A$ of size $K$. Note that $1\le A_1 \lt A_2 \lt \ldots \lt A_K = N$ and $K \le N$. Consider an array $B$ of size $N$. We define the *prefix maximum* array of $B$ as an array consisting of **all** $B_i$ (in **order**), such that $B_i \gt B_j$ for all $j \lt i$. Your task is to find the number of permutations $P$ of length $N$ such that $A$ is the *prefix maximum* array o
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