Leetcode 1329 Solution

This article provides solution to leetcode question 1329 (minimum-cost-to-move-chips-to-the-same-position)

https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position

Solution

class Solution:
    def minCostToMoveChips(self, positions: List[int]) -> int:
        odd = 0
        even = 0

        for pos in positions:
            if pos % 2 == 0:
                even += 1
            else:
                odd += 1
        return min(odd, even)