1217. Minimum Cost to Move Chips to The Same Position

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1217

class Solution:
    def minCostToMoveChips(self, position: List[int]) -> int:
        a = sum(p % 2 for p in position)
        b = len(position) - a
        return min(a, b)