A Counting Problem
Consider an array $A$ of length $N$. You know that for all $1 \leq i \leq N$, $0 \leq A_i \leq 10^5$. We construct an array $B$ of length $N-1$ such that, for all $1 \leq i \leq N - 1$, $B_i = min(A_i, A_{i + 1})$. You are given the array $B$, you need to find out the total number of distinct arrays $A$ which we could have used to construct the given array $B$. The answer may be large, so you ne
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