The Necklace
CodeChefOpen on judge ↗
Chef wants to buy a necklace for Chefina. The necklace will consist of $N$ beads joined together in a circular manner, i.e., the $1^{st}$ bead will lie between $N^{th}$ and $2^{nd}$ beads. The $2^{nd}$ bead will lie between $3^{rd}$ and $1^{st}$ beads and so on. Each bead has a certain colour (some beads can have the same colour). Chef considers the necklace good if no two neighbouring beads have
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