Pastry flavors
CodeChefOpen on judge ↗
A Pastry chef made N pieces of pastries, numbered them 1 through N and arranged them in this order in a row. There are K possible types of flavours (numbered 1 through K); for each valid i, the i-th piece of pastry has a flavour Ai. The Chef wants to select a contiguous subsegment of the pieces of pastry such that there is at least one flavour which does not occur in that subsegment. Find the max
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