Chef and His Dish
Chef is experimenting in his kitchen. He has $N$ spices (numbered $0$ through $N-1$) with types $S_0, S_1, \ldots, S_{N-1}$. You should answer $Q$ queries. Each query is described by two integers $L$ and $R$. In each query, Chef wants to use the spices $S_L, S_{L+1}, \ldots, S_R$ in some order to make a dish. However, he has no clue about the order in which he should use them to make a perfect
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