← All problemsSign in

Color Difference

CodeChefRating 3027Open on judge ↗

A flower shop has $N$ flowers for sale. These flowers are arranged in a row from left to right. The $i$-th flower has color $C_i$. You would like to buy some contiguous range of these flowers. Specifically, you've shortlisted $M$ ranges of flowers. The $i$-th range starts at index $L_i$ and ends at index $R_i$, and includes both endpoints. For two ranges $i$ and $j$ ($1 \leq i, j \leq M$)

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