← All problemsSign in

Beautiful Subsequence

CodeChefRating 2961Open on judge ↗

You are given an array $A$ of size $2N$, where every number from $1$ to $N$ occurs **exactly twice**. Consider choosing a subsequence of positions $t = (t_1, t_2, \ldots, t_M)$ with $1 \le t_1 < t_2 < \cdots < t_M \le 2N$. This subsequence is called **valid** if for every starting point $j$ with $1 \le j \le M - N + 1$, the values $A_{t_j}, A_{t_{j+1}}, \ldots, A_{t_{j+N-1}}$ are all **mutuall

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