Count Number of Peaks
You are given an integer $N$ where $N \le 10$. Consider any array $A$ with length $N$ where each element can either be $0$, $1$, or $2$, we define $f(A)$ as the number of extrema in $A$. You need to find the sum of $f(A)$ over **all** possible arrays $A$. **Note**: - In an array $A$, we consider $A_i$ as an extremum if it is strictly greater than both of its neighbors (i.e. $A_i \gt A_{i - 1}$ **
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