Free written solutionMinimum Cost to Move Chips to The Same Position (LeetCode 1217): Solution and Explanation
Chips sit at integer positions. Moving a chip by 2 is free and moving it by 1 costs 1. Find the cheapest way to stack every chip on one position. The whole problem reduces to counting even and odd positions.
Read the intuition, approach, code and complexity →