Maximum Distance
CodeChefOpen on judge ↗
Alice has $N$ integers $a_1, a_2,..., a_N$. An integer may occur multiple times in the array. Alice has to answer $Q$ queries, each query consists of two integers $x$ and $y$. Alice needs to find the maximum value of $|i-j|$ such that $a_i=x$ and $a_j=y$. Help Alice answer the $Q$ queries. ###Input: - First line contains a single integer $N$. - The second line contains $N$ space separated
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