← All problemsSign in

Arranging the Inventory

Chef has an inventory, which can be represented as a row of $N$ cells (numbered $1$ through $N$). Each cell is either empty or contains a box. Chef wants to rearrange the boxes in such a way that they are all on the left side of the inventory (so if there are $K$ boxes, they should occupy the leftmost $K$ cells). He may perform two types of moves: - choose a cell $i$ ($1 \le i \le N-2$); if cells

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