← All problemsSign in

Array Construction

You are given three integers $n$, $k$, and $x$. You need to find the number of ways to construct an array such that: - Length of array is $n$ - First element of array is $1$ i.e. $arr[0] = 1$ - Last element of array is $x$ i.e. $arr[n-1] = x$ - Values at every consecutive pair of indices should be different i.e. $arr[i]!=arr[i+1]$ for all $0<=i<=n-2$. - All elements of the array should be between

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