1217. Minimum Cost to Move Chips to The Same Position ¶ Time: Space: C++JavaPython 1 2 3 4 5 6 7 8 9class Solution { public: int minCostToMoveChips(vector<int>& position) { vector<int> count(2); for (const int p : position) ++count[p % 2]; return min(count[0], count[1]); } }; 1 2 3 4 5 6 7 8class Solution { public int minCostToMoveChips(int[] position) { int[] count = new int[2]; for (final int p : position) ++count[p % 2]; return Math.min(count[0], count[1]); } } 1 2 3 4 5 6class Solution: def minCostToMoveChips(self, position: list[int]) -> int: count = [0, 0] for p in position: count[p % 2] += 1 return min(count[0], count[1])