Shift Laddus
CodeChefOpen on judge ↗
We have $n$ Laddus, where the position of the $ith$ laddu is $position[i]$. We need to move all the laddus to the same position. In one step, we can change the position of the $ith$ laddu from $position[i]$ to: - $position[i] + 2 or position[i] - 2 with cost = 0.$ - $position[i] + 1 or position[i] - 1 with cost = 1.$ Return the minimum cost needed to move all the laddus to the same position. ##
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