Defective Item
CodeChefOpen on judge ↗
Chef has a container that opens from both ends and contains $N$ items numberd from $1$ to $N$. He realizes that one item whose value is $x$ is defective and wants to remove it from the container. To remove an item Chef has to start from one end and take out each item till the defective piece is no more there. Work done will be the sum of values of items taken out in the process (including the defe
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