ONE DISTINCT
CodeChefOpen on judge ↗
You are given an array $A$ of size $N$ and $Q$ queries of the form $[L, R]$. Consider $n$ to be the length of the segment $[L, R]$. i.e. $n = R - L + 1$. (n >= 2) If $n - 1$ numbers present between the segment $[L, R]$ (both inclusive) are $equal$ and only $one$ number is $distinct$ then you should print "$YES$" else in all other cases "$NO$" without double quotes. See sample testcase
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